Linking symbols to fixed addresses on Linux

后端 未结 3 370
南笙
南笙 2020-12-10 04:45

How would one go about linking (some) symbols to specific fixed addresses using GNU ld so that the binary could still be executed as normal in Linux (x86)? There will not be

3条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-10 05:31

    The suggestion by litb to use --defsym symbol=address does work, but is a bit cumbersome when you have a few dozen such instances to map. However, --just-symbols=symbolfile does just the trick. It took me a while to find out the syntax of the symbolfile, which is

    symbolname1 = address;
    symbolname2 = address;
    ...
    

    The spaces seem to be required, as otherwise ld reports file format not recognized; treating as linker script.

提交回复
热议问题