This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PowerPC] Garbage collecting .toc entries in a non-adhoc way (section group)


On Mon, Mar 2, 2020 at 2:59 AM Alan Modra <amodra@gmail.com> wrote:
>
> On Sun, Mar 01, 2020 at 10:56:02PM -0800, Fangrui Song wrote:
> > Now I am thinking about whether we can produce .toc in section groups to obtain garbage collection ability for free.
> >
> > .text (not in a section group) references `foo` defined in .data.rel.ro.foo (in a section group) via .toc .
> > ```
> > .text
> > addis 3,2,.LC0@toc@ha
> >
> > .section .data.rel.ro.foo,"aGw",foo,comdat
> > .globl foo
> > foo:
> >
> > .section .toc,"aGw",@progbits,foo,comdat
> > .LC0:
> > .tc foo[TC],foo
> > ```
> >
> > When `.data.rel.ro.foo` and the `.toc` are discarded due to the section
> > group rule, the relocation from `.text` to the `.toc` becomes dangling.
>
> Yes, that breaks the ELF gABI which says: "A symbol table entry with
> STB_LOCAL binding that is defined relative to one of a group's
> sections, and that is contained in a symbol table section that is not
> part of the group, must be discarded if the group members are
> discarded.  References to this symbol table entry from outside the
> group are not allowed."
>
> I think what you're trying to do is reinvent the GOT.  There isn't any
> reason why powerpc64 can't use a GOT and GOT relocations.

Yes, there is inventing the GOT. But neither GCC nor clang produces
foo@got@ha and foo@got@l pairs. Is there some hidden wisdom I am
missing?


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]