gcc - Linking symbols to fixed addresses on Linux -


How to know how to add (some) symbols for specific fixed addresses using the GNU LD so that binary is now Can also execute in Linux normal (x86)?

For example, I have the following structure:

  struct FooBar {register 32 field}; Register32 field_2; // ...}; Fubar Fobar;  

I want to link foobar to address 0x76543210, but the standard libraries and the rest of the applications are normally linked to the application then using the Address of the Fobor , But will not reference it behind (possibly non-existent) memory.

The reasoning for this request is that this single source can be used on two platforms: On the native platform, Register32 just a unstable uint32_t Maybe, but there is a C + object with Register32 a C shape on Linux UIT 32_T as defined by operator = , Which will then use the address of the object and a communication schema with that address (and data) to have real access to the remote address Sends a request for the order. The linker will thus ensure that the Register32 field of the structure refers to the correct "address".

Tips for using - defsym symbol = address by LitBab Does, but there is some complexity when you have a few dozen maps that use the map. However, I did take some time to find the symbolfile syntax for - just-symbols = simbofilefile moves only

  symbolname1 = Address; Symbol name2 = address; ...  

Spaces are required because otherwise the ld report file format is not recognized; Treating the linker script as .


Comments