[PATCH 6/6] aix: implement TLS relocation for gas and ld
Alan Modra
amodra@gmail.com
Fri Feb 26 10:54:49 GMT 2021
On Tue, Feb 16, 2021 at 09:59:48AM +0000, CHIGOT, CLEMENT wrote:
> * bfd-in2.h (BFD_RELOC_PPC_TLS{LE, IE, M, ML})
> (BFD_RELOC_PPC64_TLS{GD, LD, LE, IE, M, ML}): New defines.
bfd-in2.h and libbfd.h are generated files, as the comment at the
start of those files says. New BFD_RELOC values belong in reloc.c,
and please list each value in the changelog like
* reloc.c (BFD_RELOC_PPC_TLSLE, BFD_RELOC_PPC_TLSIE),
(BFD_RELOC_PPC_TLSM, BFD_RELOC_PPC_TLSML),
(BFD_RELOC_PPC64_TLSGD, BFD_RELOC_PPC64_TLSLD),
(BFD_RELOC_PPC64_TLSLE, BFD_RELOC_PPC64_TLSIE),
(BFD_RELOC_PPC64_TLSM, BFD_RELOC_PPC64_TLSML): New relocs.
* bfd-in2.h: Regenerate.
* libbfd.h: Regenerate.
The same applies to the patch adding extra TOC16 relocs, those should
be added to reloc.c too. And the same for the rest of the changelog,
the idea being that someone searching for say, R_TLS_LE, won't hit
your changelog entry. You don't need to enumerate all the new relocs
each place they are used though, just "new relocs" will do once you
have enumerated them once in the changelog.
> --- a/ld/emultempl/aix.em
> +++ b/ld/emultempl/aix.em
> @@ -969,6 +969,26 @@ gld${EMULATION_NAME}_before_allocation (void)
> sec->flags |= SEC_KEEP;
> }
>
> + /* Make sure .tdata is removed if empty, even with -r flag.
> + .tdata is always being generated because its size is needed
> + to cumpute .data address. */
> + if (bfd_link_relocatable (&link_info))
> + {
> + asection *sec;
> +
> + sec = bfd_get_section_by_name (link_info.output_bfd,
> + ".tdata");
Needs a "sec != NULL" test here, and I think even with that this code
won't work as you expect. I might be wrong though, did you test to
see whether a non-empty .tdata is kept?
> + if (sec->rawsize == 0
> + && (sec->flags & SEC_KEEP) == 0
> + && !bfd_section_removed_from_list (link_info.output_bfd,
> + sec))
> + {
> + sec->flags |= SEC_EXCLUDE;
> + bfd_section_list_remove (link_info.output_bfd, sec);
> + link_info.output_bfd->section_count--;
> + }
> + }
> +
> before_allocation_default ();
> }
--
Alan Modra
Australia Development Lab, IBM
More information about the Binutils
mailing list