1999-05-03 15:29:11 +08:00
|
|
|
# AIX linker script.
|
|
|
|
# AIX always uses shared libraries. The section VMA appears to be
|
|
|
|
# unimportant. The native linker aligns the sections on boundaries
|
|
|
|
# specified by the -H option.
|
2014-08-20 17:34:58 +08:00
|
|
|
#
|
2023-01-01 14:08:42 +08:00
|
|
|
# Copyright (C) 2014-2023 Free Software Foundation, Inc.
|
2017-10-12 18:58:30 +08:00
|
|
|
#
|
2014-08-20 17:34:58 +08:00
|
|
|
# Copying and distribution of this file, with or without modification,
|
|
|
|
# are permitted in any medium without royalty provided the copyright
|
|
|
|
# notice and this notice are preserved.
|
2001-12-04 07:15:28 +08:00
|
|
|
|
1999-05-03 15:29:11 +08:00
|
|
|
cat <<EOF
|
2023-01-01 14:08:42 +08:00
|
|
|
/* Copyright (C) 2014-2023 Free Software Foundation, Inc.
|
2014-08-20 17:34:58 +08:00
|
|
|
|
|
|
|
Copying and distribution of this script, with or without modification,
|
|
|
|
are permitted in any medium without royalty provided the copyright
|
|
|
|
notice and this notice are preserved. */
|
|
|
|
|
1999-05-03 15:29:11 +08:00
|
|
|
OUTPUT_ARCH(${ARCH})
|
|
|
|
${RELOCATING+${LIB_SEARCH_DIRS}}
|
2009-09-09 19:59:14 +08:00
|
|
|
${RELOCATING+ENTRY (__start)}
|
1999-05-03 15:29:11 +08:00
|
|
|
SECTIONS
|
|
|
|
{
|
|
|
|
.pad 0 : { *(.pad) }
|
2001-05-25 04:59:23 +08:00
|
|
|
|
2011-11-03 19:53:39 +08:00
|
|
|
. = ALIGN (0x10000000 + SIZEOF_HEADERS, 32);
|
2009-10-10 12:34:39 +08:00
|
|
|
.text ${RELOCATING-0} : {
|
1999-05-03 15:29:11 +08:00
|
|
|
${RELOCATING+PROVIDE (_text = .);}
|
|
|
|
*(.text)
|
|
|
|
*(.pr)
|
|
|
|
*(.ro)
|
|
|
|
*(.db)
|
|
|
|
*(.gl)
|
|
|
|
*(.xo)
|
|
|
|
*(.ti)
|
|
|
|
*(.tb)
|
|
|
|
${RELOCATING+PROVIDE (_etext = .);}
|
|
|
|
}
|
2011-11-03 19:53:39 +08:00
|
|
|
|
aix: implement TLS relocation for gas and ld
Add support for TLS in XCOFF. Amongst the things done by this commit:
- Update XCOFF auxialiary header to match new version and allow TLS
sections.
- Add TLS sections (.tdata and .tbss) support in gas and ld.
- Add support for the TLS relocations in gas and ld.
Two different types BFD_RELOC are created for PPC and PPC64 as
the size is a pointer, thus distinct in 32 or 64bit.
The addresses given by ld to .tdata and .tbss is a bit special. In
XCOFF, these addresses are actually offsets from the TLS pointer
computed at runtime. AIX assembly and linker does the same. In
top of that, the .tdata must be before .data (this is mandatory for AIX
loader). Thus, the aix ld script is recomputing "." before .data to restore
its original value. There might be a simpler way, but this one is working.
Optimisation linked to TLS relocations aren't yet implemented.
bfd/
* reloc.c (BFD_RELOC_PPC_TLS_LE, BFD_RELOC_PPC_TLS_IE,
BFD_RELOC_PPC_TLS_M, BFD_RELOC_PPC_TLS_ML, BFD_RELOC_PPC64_TLS_GD,
BFD_RELOC_PPC64_TLS_LD, BFD_RELOC_PPC64_TLS_LE,
BFD_RELOC_PPC64_TLS_IE, BFD_RELOC_PPC64_TLS_M,
BFD_RELOC_PPC64_TLS_ML): New relocations.
* bfd-in2.h: Regenerate.
* libbfd.h: Regenerate.
* coff-rs6000.c (xcoff_calculate_relocation): Call
xcoff_reloc_type_tls for TLS relocations.
(xcoff_howto_table): Implement TLS relocations.
(_bfd_xcoff_reloc_type_lookup): Add cases TLS relocations.
(xcoff_reloc_type_tls): New function.
* coff64-rs6000.c (xcoff_calculate_relocation): Likewise.
(xcoff_howto_table): Likewise.
(_bfd_xcoff_reloc_type_lookup): Likewise.
* coffcode.h (sec_to_styp_flags): Handle TLS sections.
(styp_to_sec_flags): Likewise.
(coff_compute_section_file_positions): Avoid file offset
optimisation for .data when the previous section is .tdata.
(coff_write_object_contents): Handle TLS sections.
* coffswap.h (coff_swap_aouthdr_out): Add support for
new fields in aouthdr.
* libxcoff.h (xcoff_reloc_type_tls): Add prototype.
* xcofflink.c (xcoff_link_add_symbols): Handle XMC_UL.
(xcoff_need_ldrel_p): Add cases for TLS relocations.
(xcoff_create_ldrel): Add l_symndx for TLS sections.
gas/
* config/tc-ppc.c (ppc_xcoff_text_section, ppc_xcoff_data_section,
(ppc_xcoff_bss_section, ppc_xcoff_tdata_section,
(ppc_xcoff_tbss_section): New variables.
(ppc_text_subsegment, ppc_text_csects, ppc_data_subgments,
(ppc_data_csects): Removed.
(ppc_xcoff_section_is_initialized, ppc_init_xcoff_section,
ppc_xcoff_parse_cons): New functions.
(md_being): Initialize XCOFF sections.
(ppc_xcoff_suffix): Add support for TLS relocations
(fixup_size, md_apply_fix): Add support for new BFD_RELOC.
(ppc_change_csect): Handle XMC_TL, XMC_UL. Correctly, add XMC_BS
to .bss section. Handle new XCOFF section variables.
(ppc_comm): Likewise.
(ppc_toc): Likewise.
(ppc_symbol_new_hook): Likewise.
(ppc_frob_symbol): Likewise.
(ppc_fix_adjustable): Add tbss support.
* config/tc-ppc.h (TC_PARSE_CONS_EXPRESSION): New define.
(ppc_xcoff_parse_cons): Add prototype.
(struct ppc_xcoff_section): New structure.
ld/
* emultempl/aix.em: Ensure .tdata section is removed
if empty, even with -r flag.
* scripttempl/aix.sc: Handle TLS sections.
* testsuite/ld-powerpc/aix52.exp: Add new tests.
* testsuite/ld-powerpc/aix-tls-reloc-32.d: New test.
* testsuite/ld-powerpc/aix-tls-reloc-64.d: New test.
* testsuite/ld-powerpc/aix-tls-reloc.ex: New test.
* testsuite/ld-powerpc/aix-tls-reloc.s: New test.
* testsuite/ld-powerpc/aix-tls-section-32.d: New test.
* testsuite/ld-powerpc/aix-tls-section-64.d: New test.
* testsuite/ld-powerpc/aix-tls-section.ex: New test.
* testsuite/ld-powerpc/aix-tls-section.s: New test.
include/
* coff/internal.h (struct internal_aouthdr): Add new fields.
* coff/rs6000.h (AOUTHDRÃ): Add new fields.
* coff/rs6k64.h (struct external_filehdr): Likewise.
* coff/xcoff.h (_TDATA), _TBSS): New defines
(RS6K_AOUTHDR_TLS_LE, RS6K_AOUTHDR_RAS, RS6K_AOUTHDR_ALGNTDATA,
RS6K_AOUTHDR_SHR_SYMTAB, RS6K_AOUTHDR_FORK_POLICY,
RS6K_AOUTHDR_FORK_COR): New defines.
(XMC_TU): Removed.
(XMC_UL): New define.
2021-03-11 18:08:19 +08:00
|
|
|
/* .tdata and .tbss addresses are representing the offset from
|
|
|
|
the TLS pointer. It starts at -0x7800 for 64bit and -0x7c00
|
|
|
|
for 32bit.
|
|
|
|
TODO: 32bit should have -0x7c00 but it works like this for
|
|
|
|
now.
|
|
|
|
The other particularity is that they must be before .data
|
|
|
|
sections. But .data must be aligned correctly as if the
|
|
|
|
addresses were contiguous. This means that the correct
|
|
|
|
address must be restored, taking into account: the size of
|
|
|
|
.text, its alignment 2^5, the size of .tdata and its
|
|
|
|
aligment 2^4. */
|
|
|
|
.tdata -0x7800 : {
|
|
|
|
*(.tdata)
|
|
|
|
*(.tl)
|
|
|
|
}
|
|
|
|
|
|
|
|
.tbss : {
|
|
|
|
*(.tbss)
|
|
|
|
*(.ul)
|
|
|
|
}
|
|
|
|
|
|
|
|
. = ${RELOCATING+(ALIGN (0x10000000 + SIZEOF_HEADERS, 32)) + }SIZEOF(.text);
|
|
|
|
. = ALIGN (.,32);
|
|
|
|
. = . + SIZEOF(.tdata);
|
|
|
|
. = ALIGN (.,16);
|
|
|
|
|
|
|
|
/* .data starting address must be in a different segment than
|
|
|
|
the .text addresses. Thus, 0x10000000 is added. */
|
|
|
|
. = ALIGN (0x10000000) + (. & 0xfff);
|
2001-05-25 04:59:23 +08:00
|
|
|
.data . : {
|
1999-05-03 15:29:11 +08:00
|
|
|
${RELOCATING+PROVIDE (_data = .);}
|
|
|
|
*(.data)
|
|
|
|
*(.rw)
|
|
|
|
*(.sv)
|
2001-05-25 04:59:23 +08:00
|
|
|
*(.sv64)
|
|
|
|
*(.sv3264)
|
1999-05-03 15:29:11 +08:00
|
|
|
*(.ua)
|
|
|
|
. = ALIGN(4);
|
|
|
|
${CONSTRUCTING+CONSTRUCTORS}
|
|
|
|
*(.ds)
|
|
|
|
*(.tc0)
|
|
|
|
*(.tc)
|
|
|
|
*(.td)
|
2021-03-11 18:08:19 +08:00
|
|
|
*(.te)
|
1999-05-03 15:29:11 +08:00
|
|
|
${RELOCATING+PROVIDE (_edata = .);}
|
|
|
|
}
|
|
|
|
.bss : {
|
|
|
|
*(.tocbss)
|
|
|
|
*(.bss)
|
|
|
|
*(.bs)
|
|
|
|
*(.uc)
|
|
|
|
*(COMMON)
|
|
|
|
${RELOCATING+PROVIDE (_end = .);}
|
|
|
|
${RELOCATING+PROVIDE (end = .);}
|
|
|
|
}
|
2001-05-25 04:59:23 +08:00
|
|
|
|
|
|
|
.loader : {
|
1999-05-03 15:29:11 +08:00
|
|
|
*(.loader)
|
|
|
|
}
|
2017-10-12 18:58:30 +08:00
|
|
|
|
2001-05-25 04:59:23 +08:00
|
|
|
.debug : {
|
1999-05-03 15:29:11 +08:00
|
|
|
*(.debug)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
EOF
|