[cfe-dev] Why clang creates ELF section group with only one section in it?

Rafael EspĂ­ndola rafael.espindola at gmail.com
Mon May 14 14:07:35 PDT 2012


> But then it makes sense to put relocs against this section in the same group
> also so they can be discarded together (as Sun C++ does).

I am not sure I understand. The regular way of relocations are
recorded on ELF is by having a relocation section for each section
that needs one. In your example we have (both gcc and clang):

Relocation section '.rela.text' at offset 0x690 contains 1 entries:
    Offset             Info             Type               Symbol's
Value  Symbol's Name + Addend
000000000000000a  0000000b00000002 R_X86_64_PC32
0000000000000000 _Z3barIiEiT_ - 4

It is a relocation on .text that points to _Z3barIiEiT_. We also have

Relocation section '.rela.text._Z3barIiEiT_' at offset 0x6a8 contains 1 entries:
    Offset             Info             Type               Symbol's
Value  Symbol's Name + Addend
0000000000000013  0000000c00000002 R_X86_64_PC32
0000000000000000 _ZN1SD1Ev -

Which is a relocation *in* _Z3barIiEiT_. Note that _Z3barIiEiT_ is
*not* STB_LOCAL.

Cheers,
Rafael



More information about the cfe-dev mailing list