kameler
kameler

Reputation: 1

How is the address of the .rodata section determined in ELF files compiled using GCC and ld?

I have an old executable ELF file. Now, I recompile its source files using the same version of GCC and a similar compilation environment (almost same).

However, when I used readelf to explore the symbol address of this old and newly compiled executable ELF file, the symbol address in the .rodata section changed(symbol size not change.), and nothing else changed.

part of compare:

old address          section  symbol                     |new address          section  symbol

000000000004c5d0 .text   memory_region_finalize          | 000000000004c5d0 .text   memory_region_finalize

000000000004c680 .rodata l2cap_fcs16_table               | 

000000000004c680 .text   memory_region_set_enabled       | 000000000004c680 .text   memory_region_set_enabled

000000000004c6d0 .text   memory_region_set_size          | 000000000004c6d0 .text   memory_region_set_size

                                                         | 000000000004c720 .rodata l2cap_fcs16_table

000000000004c740 .text   memory_region_set_address       | 000000000004c740 .text   memory_region_set_address

000000000004c7c0 .text   memory_region_set_alias_offset  | 000000000004c7c0 .text   memory_region_set_alias_offset

000000000004c840 .text   memory_region_get_alignment     | 000000000004c840 .text   memory_region_get_alignment

000000000004c850 .text   memory_region_is_mapped         | 000000000004c850 .text   memory_region_is_mapped

000000000004c860 .text   memory_region_find              | 000000000004c860 .text   memory_region_find

000000000004c954 .rodata bt_base_uuid                    | 

000000000004c960 .text   memory_region_present           | 000000000004c960 .text   memory_region_present

                                                         | 000000000004c9f4 .rodata bt_base_uuid

000000000004ca10 .text   address_space_sync_dirty_bitmap | 000000000004ca10 .text   address_space_sync_dirty_bitmap

Why is that? Can I get the new executable ELF file exactly the same, and its .rodata section symbol address is the same as the old executable file? and how? Many thanks!

Upvotes: 0

Views: 1020

Answers (1)

jiachen chang
jiachen chang

Reputation: 21

All scetion addresses are defined by the ld link script. You can use ld --verbose to view the current default link script.

Upvotes: 0

Related Questions