V2 [PATCH] ELF: Don't generate unused section symbols

Fangrui Song i@maskray.me
Thu Jan 7 20:32:33 GMT 2021


On 2021-01-07, Nick Clifton via Binutils wrote:
>Hi H.J.
>
>>>>Tested on Linux/x86.  Other ELF backends need:
>>>>
>>>>1. Mark used section symbols in assembler backend.
>>>>2. Remove unused section symbols from expected assembler and linker
>>>>outputs.
>>>
>>>In that case definitely not something we want before 2.36 goes out the
>>>door.
>>>
>>
>>Here is the updated patch to make the new behavior opt-in.
>>OK for master?
>
>Yes - approved - please apply.
>

Hi, H.J.

Thanks for the patch. This will save a lot of space in .o/.a files.

For some differences, I think there is an objdump -d problem:

- +[a-f0-9]+:   ff 15 28 01 20 00       call   \*0x200128\(%rip\)        # 2002f8 <.got>
- +[a-f0-9]+:   ff 25 2a 01 20 00       jmp    \*0x20012a\(%rip\)        # 200300 <.got\+0x8>
- +[a-f0-9]+:   48 c7 05 1f 01 20 00 00 00 00 00        movq   \$0x0,0x20011f\(%rip\)        # 200300 <.got\+0x8>
- +[a-f0-9]+:   48 83 3d 0f 01 20 00 00         cmpq   \$0x0,0x20010f\(%rip\)        # 2002f8 <.got>
- +[a-f0-9]+:   48 3b 0d 08 01 20 00    cmp    0x200108\(%rip\),%rcx        # 2002f8 <.got>
- +[a-f0-9]+:   48 3b 0d 09 01 20 00    cmp    0x200109\(%rip\),%rcx        # 200300 <.got\+0x8>
+ +[a-f0-9]+:   ff 15 28 01 20 00       call   \*0x200128\(%rip\)        # 2002f8 <_DYNAMIC\+0x100>
+ +[a-f0-9]+:   ff 25 2a 01 20 00       jmp    \*0x20012a\(%rip\)        # 200300 <_DYNAMIC\+0x108>
+ +[a-f0-9]+:   48 c7 05 1f 01 20 00 00 00 00 00        movq   \$0x0,0x20011f\(%rip\)        # 200300 <_DYNAMIC\+0x108>
+ +[a-f0-9]+:   48 83 3d 0f 01 20 00 00         cmpq   \$0x0,0x20010f\(%rip\)        # 2002f8 <_DYNAMIC\+0x100>
+ +[a-f0-9]+:   48 3b 0d 08 01 20 00    cmp    0x200108\(%rip\),%rcx        # 2002f8 <_DYNAMIC\+0x100>
+ +[a-f0-9]+:   48 3b 0d 09 01 20 00    cmp    0x200109\(%rip\),%rcx        # 200300 <_DYNAMIC\+0x108>

.got+0x8 (a small offset) should be preferred over _DYNAMIC+0x108 (a large offset),
regardless of whether STT_SECTION .got exists (I don't check how ld behaves differently with the gas change).

I think this is an existing objdump issue (https://sourceware.org/bugzilla/show_bug.cgi?id=24702).
The commit just reveals more instances.


More information about the Binutils mailing list