Commit Graph

143 Commits

Author SHA1 Message Date
Indu Bhagat
47c88752f9 ld: generate SFrame stack trace info for .plt.got
PR/32298 sframe: no SFrame stack trace info generated for .plt.got

Add support to generate SFrame stack trace info for .plt.got section.
Enhance the current definition of struct elf_x86_sframe_plt to include
initialized SFrame FDE/FREs applicable for .plt.got section.  There are
two variants of .plt.got entries: 16 byte and 8 byte.

8 byte:
    ff 25 00 00 00 00     jmpq  *name@GOTPCREL(%rip)
    66 90                 xchg  %ax,%ax

16 byte:
    f3 0f 1e fa           endbr64
    ff 25 66 2f 00 00     jmpq  *name@GOTPCREL(%rip)
    66 0f 1f 44 00 00     nopw   0x0(%rax,%rax,1)

For the testcase, define some application symbols such that their PLT
entry is placed in .plt.got and ensure SFrame information is generated
with and without -z ibtplt.

ChangeLog:
	PR/32298
	* bfd/elf64-x86-64.c (elf_x86_64_link_setup_gnu_properties):
	PLT GOT entry size is different for IBT vs non IBT PLTs.
	* bfd/elfxx-x86.c (enum dynobj_sframe_plt_type): New enum for
	SFRAME_PLT_GOT.
	(_bfd_x86_elf_create_sframe_plt): Handle SFRAME_PLT_GOT.
	(_bfd_x86_elf_write_sframe_plt): Likewise.
	(_bfd_x86_elf_late_size_sections): Likewise.
	(_bfd_x86_elf_finish_dynamic_sections): Likewise.
	* bfd/elfxx-x86.h (struct elf_x86_sframe_plt): Add new members
	to keep information about PLT GOT entries.
	(struct elf_x86_link_hash_table): Add support for creating
	SFrame section for .plt.got.
	* ld/testsuite/ld-x86-64/x86-64.exp: Add new tests.
	* ld/testsuite/ld-x86-64/sframe-pltgot-1.d: New test.
	* ld/testsuite/ld-x86-64/sframe-pltgot-1.s: New test.
	* ld/testsuite/ld-x86-64/sframe-pltgot-2.d: New test.
2024-11-01 15:36:35 -07:00
Josh Poimboeuf
938fb51218 ld: fix wrong SFrame info for lazy IBT PLT
Fix PR/32296 sframe: wrong SFrame info for pltN and .plt.sec for -z ibtplt

The x86 psABI defines a 2-PLT scheme for IBT which uses .plt and
.plt.sec entries.  It was observed that SFrame information for .plt.sec
section was incorrect.  The erroneous assumption was that SFrame stack
trace information for .plt.sec with lazy binding is the same as SFrame
stack trace information for .plt with lazy binding.  This is corrected
now by initializing a new SFrame PLT helper object
elf_x86_64_sframe_ibt_plt for lazy PLT with IBT.

Add a testcase where linking with -z ibtplt generates .plt.sec entries and
ensure correct SFrame information for it.

Committed by Indu Bhagat.

ChangeLog:
	PR/32296
	* bfd/elf64-x86-64.c (elf_x86_64_sframe_ibt_pltn_fre2): New
	definition elf_x86_64_sframe_ibt_plt.  Use it in
	elf_x86_64_sframe_plt.
	(elf_x86_64_link_setup_gnu_properties): Lazy IBT PLT entries are
	different from lazy PLT.
        * bfd/elfxx-x86.c (_bfd_x86_elf_create_sframe_plt): Adjust for
	SFrame for IBT PLT.
        * ld/testsuite/ld-x86-64/x86-64.exp: Add new test.
        * ld/testsuite/ld-x86-64/sframe-ibt-plt-1.d: New test.
2024-11-01 15:36:03 -07:00
Josh Poimboeuf
1785837a25 ld: fix PR/32297
When _creating_ SFrame information for the linker created .plt.sec, the
code correctly checks for presence of .plt.sec.  When _writing_ the
SFrame section for the corresponding .plt.sec, however, the conditionals
were wrongly checking for splt.  This was causing an assertion at link
time.

This issue has been known to affect glibc build with SFrame enabled.

No testcase is added just yet.  A later commit ensures correct SFrame
stack trace information is created for .plt.got. A test case (where only
.plt and .plt.got are created) is added then.

PR/32297 sframe: bfd assertion with empty main on IBT enabled system

Committed by Indu Bhagat.

ChangeLog:
	PR/32297
	* bfd/elfxx-x86.c (_bfd_x86_elf_late_size_sections): Check for
	  plt_second member not for splt.
2024-11-01 15:31:21 -07:00
Alan Modra
9b09ceea7d Revert "get_synthetic_symtab fixes for commit 68bbe1183379"
This reverts commit 0c13ac533e.
2024-10-08 15:12:14 +10:30
Alan Modra
0c13ac533e get_synthetic_symtab fixes for commit 68bbe11833
Given that relocation symbol name can now be NULL for ELF, adjust
various get_synthetic_symtab routines so they don't segfault.

	* elf.c (_bfd_elf_get_synthetic_symtab): Cope with sym->name
	possibly being NULL.
	* elf32-arm.c (elf32_arm_get_synthetic_symtab): Likewise.
	* elf32-ppc.c (ppc_elf_get_synthetic_symtab): Likewise.
	* elf64-ppc.c (ppc64_elf_get_synthetic_symtab): Likewise.
	* elfxx-mips.c (_bfd_mips_elf_get_synthetic_symtab): Likewise.
	* elfxx-x86.c (_bfd_x86_elf_get_synthetic_symtab): Likewise.
2024-10-04 17:47:21 +09:30
H.J. Lu
c9652a062f x86: Report expected register for elf_x86_tls_error_indirect_call
Since R_386_TLS_DESC_CALL can only be used with

	call	*variable@TLSCALL(%eax)

and R_X86_64_TLSDESC_CALL can only be used with

	call	*variable@TLSCALL(%rax)

update TLS transition error report to display the expected register in
indirect CALL.

bfd/

	PR ld/32017
	* elfxx-x86.c (_bfd_x86_elf_link_hash_table_create): Initialize
	the ax_register field.
	(_bfd_x86_elf_link_report_tls_transition_error): Report the
	expected register in elf_x86_tls_error_indirect_call error.
	* elfxx-x86.h (elf_x86_link_hash_table): Add ax_register.

ld/

	PR ld/32017
	* testsuite/ld-i386/tlsgdesc2.d: Updated.
	* testsuite/ld-i386/tlsgdesc2.s: Change jmp to call via ECX.
	* testsuite/ld-x86-64/tlsdesc4.d: Updated.
	* testsuite/ld-x86-64/tlsdesc4.s: Change jmp to call via RCX.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
2024-08-28 05:56:25 -07:00
H.J. Lu
f73f5173fa x86: Add missing newlines in TLS transition error messages
Change TLS transition error messages from

a-argp-help.o(.text+0x12f): relocation R_X86_64_GOTTPOFF against `a' must be used in ADD or MOV onlyld: final link failed: bad value

to

a-argp-help.o(.text+0x12f): relocation R_X86_64_GOTTPOFF against `a' must be used in ADD or MOV only
ld: final link failed: bad value

	PR ld/32017
	* elfxx-x86.c (_bfd_x86_elf_link_report_tls_transition_error):
	Add missing newlines.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
2024-07-25 13:03:19 -07:00
H.J. Lu
1d68a49ac5 x86: Improve TLS transition error check
Provide detailed TLS transition errors when unsupported instructions are
used.  Treat R_X86_64_CODE_4_GOTTPOFF and R_X86_64_CODE_6_GOTTPOFF as
R_X86_64_GOTTPOFF when performing TLS transition.

bfd/

	PR ld/32017
	* elf32-i386.c (elf_i386_check_tls_transition): Return different
	enums for different errors.
	(elf_i386_tls_transition): Change argument from r_symndx to sym.
	Call _bfd_x86_elf_link_report_tls_transition_error to report TLS
	transition errors.
	(elf_i386_scan_relocs): Pass isym instead of r_symndx to
	elf_i386_tls_transition.
	(elf_i386_relocate_section): Pass sym instead of r_symndx to
	elf_i386_tls_transition.
	* elf64-x86-64.c (elf_x86_64_check_tls_transition): Return
	different enums for different errors.
	(elf_x86_64_tls_transition): Change argument from r_symndx to sym.
	Treat R_X86_64_CODE_4_GOTTPOFF and R_X86_64_CODE_6_GOTTPOFF as
	R_X86_64_GOTTPOFF.  Call
	_bfd_x86_elf_link_report_tls_transition_error to report TLS
	transition errors.
	(elf_x86_64_scan_relocs): Pass isym instead of r_symndx to
	elf_x86_64_tls_transition.
	(elf_x86_64_relocate_section): Pass sym instead of r_symndx to
	elf_x86_64_tls_transition.
	* elfxx-x86.c (_bfd_x86_elf_link_report_tls_transition_error): New.
	* elfxx-x86.h (elf_x86_tls_error_type): Likewise.
	(_bfd_x86_elf_link_report_tls_transition_error): Likewise.

ld/

	PR ld/32017
	* testsuite/ld-i386/i386.exp: Run tlsgdesc1 and tlsgdesc2.
	* testsuite/ld-i386/tlsie2.d: Updated.
	* testsuite/ld-i386/tlsie3.d: Likewise.
	* testsuite/ld-i386/tlsie4.d: Likewise.
	* testsuite/ld-i386/tlsie5.d: Likewise.
	* testsuite/ld-x86-64/tlsie2.d: Likewise.
	* testsuite/ld-x86-64/tlsie3.d: Likewise.
	* testsuite/ld-i386/tlsgdesc1.d: New file.
	* testsuite/ld-i386/tlsgdesc1.s: Likewise.
	* testsuite/ld-i386/tlsgdesc2.d: Likewise.
	* testsuite/ld-i386/tlsgdesc2.s: Likewise.
	* testsuite/ld-x86-64/tlsdesc3.d: Likewise.
	* testsuite/ld-x86-64/tlsdesc3.s: Likewise.
	* testsuite/ld-x86-64/tlsdesc4.d: Likewise.
	* testsuite/ld-x86-64/tlsdesc4.s: Likewise.
	* testsuite/ld-x86-64/tlsie5.d: Likewise.
	* testsuite/ld-x86-64/tlsie5.s: Likewise.
	* testsuite/ld-x86-64/x86-64.exp: Run tlsie5, tlsdesc3 and
	tlsdesc4.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
2024-07-25 12:40:19 -07:00
H.J. Lu
93548ee191 x86: Add -z isa-level-report=[none|all|needed|used]
Add -z isa-level-report=[none|all|needed|used] to the x86 ELF linker to
report needed and used x86-64 ISA levels.

bfd/

	PR ld/31868
	* elf-linker-x86.h (elf_x86_isa_level_report): New.
	(elf_linker_x86_params): Add isa_level_report.
	* elfxx-x86.c (report_isa_level): New.
	(_bfd_x86_elf_link_setup_gnu_properties): Check
	-z isa-level-report=[none|all|needed|used] to report needed and
	used x86-64 ISA level.

ld/

	PR ld/31868
	* NEWS: Mention -z isa-level-report=[none|all|needed|used].
	* ld.texi: Document -z isa-level-report=[none|all|needed|used].
	* emulparams/elf32_x86_64.sh: Source x86-64-level-report.sh.
	* emulparams/elf_i386.sh: Likewise.
	* emulparams/elf_x86_64.sh: Likewise.
	* emulparams/x86-64-level-report.sh: New file.
	* testsuite/ld-i386/pr31868a.d: Likewise.
	* testsuite/ld-i386/pr31868b.d: Likewise.
	* testsuite/ld-i386/pr31868c.d: Likewise.
	* testsuite/ld-x86-64/pr31868a-x32.d: Likewise.
	* testsuite/ld-x86-64/pr31868a.d: Likewise.
	* testsuite/ld-x86-64/pr31868a.l: Likewise.
	* testsuite/ld-x86-64/pr31868a.s: Likewise.
	* testsuite/ld-x86-64/pr31868b-x32.d: Likewise.
	* testsuite/ld-x86-64/pr31868b.d: Likewise.
	* testsuite/ld-x86-64/pr31868b.l: Likewise.
	* testsuite/ld-x86-64/pr31868b.s: Likewise.
	* testsuite/ld-x86-64/pr31868c-x32.d: Likewise.
	* testsuite/ld-x86-64/pr31868c.d: Likewise.
	* testsuite/ld-x86-64/pr31868c.l: Likewise.
	* testsuite/ld-i386/i386.exp: Run PR ld/31868 tests.
	* testsuite/ld-x86-64/x86-64.exp: Likewise.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
2024-06-14 13:38:19 -07:00
Indu Bhagat
7922c42688 bfd: sframe: minor code adjustments and fix typos
bfd/
	* elfxx-x86.c (_bfd_x86_elf_create_sframe_plt): Use local
	variable.
	(_bfd_x86_elf_size_dynamic_sections): Fix typos.
2024-05-17 11:24:28 -07:00
H.J. Lu
c3460201a6 elf: Fix a memory leak in _bfd_elf_add_dynamic_entry
Normally, the section contents is allocated by bfd_alloc which is freed
when the object is closed.  But the .dynamic section contents is allocated
by bfd_realloc, which should be freed by calling free.  Add a dynamic
field to elf_link_hash_table for the .dynamic section and free its
contents in _bfd_elf_link_hash_table_free.

	* elf-bfd.h (elf_link_hash_table): Add dynamic.
	* elflink.c (_bfd_elf_link_create_dynamic_sections): Set the
	dynamic field in elf_link_hash_table.
	(_bfd_elf_add_dynamic_entry): Use hash_table->dynamic.
	(_bfd_elf_strip_zero_sized_dynamic_sections): Likewise.
	(bfd_elf_add_dt_needed_tag): Likewise.
	(elf_finalize_dynstr): Likewise.
	(_bfd_elf_link_hash_table_free): Free htab->dynamic->contents.
	(bfd_elf_final_link): Use htab->dynamic.
	* elfxx-x86.c (_bfd_x86_elf_finish_dynamic_sections): Use
	htab->elf.dynamic.
2024-04-10 19:50:01 -07:00
H.J. Lu
584b30e4b3 elf: Add _bfd_elf_m[un]map_section_contents
Add _bfd_elf_mmap_section_contents and _bfd_elf_munmap_section_contents.
A backend must opt-in to use mmap.  It should replace

bfd_malloc_and_get_section -> _bfd_elf_mmap_section_contents
free			   -> _bfd_elf_munmap_section_contents

on section contents.

	* compress.c (bfd_get_full_section_contents): Don't allocate
	buffer if mmapped_p is true.
	* elf-bfd.h (elf_backend_data): Add use_mmap.
	(bfd_elf_section_data): Add contents_addr and contents_size.
	(_bfd_elf_mmap_section_contents): New.
	(_bfd_elf_munmap_section_contents): Likewise.
	* elf-eh-frame.c (_bfd_elf_parse_eh_frame): Replace
	bfd_malloc_and_get_section and free with
	_bfd_elf_mmap_section_contents and _bfd_elf_munmap_section_contents
	on section contents.
	* elf-sframe.c (_bfd_elf_parse_sframe): Likewise.
	* elf.c (_bfd_elf_make_section_from_shdr): Replace
	bfd_malloc_and_get_section and free with
	_bfd_elf_mmap_section_contents and _bfd_elf_munmap_section_contents
	on section contents.
	(_bfd_elf_print_private_bfd_data): Likewise.
	(_bfd_elf_mmap_section_contents): New.
	(_bfd_elf_munmap_section_contents): Likewise.
	* elf32-i386.c (elf_i386_scan_relocs): Replace
	bfd_malloc_and_get_section and free with
	_bfd_elf_mmap_section_contents and _bfd_elf_munmap_section_contents
	on section contents.
	* elf64-x86-64.c (elf_x86_64_scan_relocs): Likewise.
	(elf_x86_64_get_synthetic_symtab): Likewise.
	* elfcode.h (elf_checksum_contents): Likewise.
	* elflink.c (elf_link_add_object_symbols): Likewise.
	(bfd_elf_get_bfd_needed_list): Likewise.
	* elfxx-target.h (elf_backend_use_mmap): New.
	(elfNN_bed): Add elf_backend_use_mmap.
	* elfxx-x86.c (elf_x86_size_or_finish_relative_reloc): Replace
	bfd_malloc_and_get_section and free with
	_bfd_elf_mmap_section_contents and _bfd_elf_munmap_section_contents
	on section contents.
	(_bfd_x86_elf_get_synthetic_symtab): Replace free with
	_bfd_elf_munmap_section_contents.
	* elfxx-x86.h (elf_backend_use_mmap): New.
	* libbfd.c: Include "elf-bfd.h".
	(_bfd_generic_get_section_contents): Call bfd_mmap_local for
	mmapped_p.
	* opncls.c (_bfd_delete_bfd): Also munmap ELF section contents.
	* section.c (asection): Add mmapped_p.
	(BFD_FAKE_SECTION): Updated.
	(bfd_malloc_and_get_section): Add a sanity check for not
	mmapped_p.
	* bfd-in2.h: Regenerated.
2024-04-03 09:11:03 -07:00
Alan Modra
af969b14ae PR 30569, always call elf_backend_size_dynamic_sections
This largely mechanical patch is preparation for a followup patch.

For quite some time I've thought that it would be useful to call
elf_backend_size_dynamic_sections even when no dynamic objects are
seen by the linker.  That's what this patch does, with some renaming.
There are no functional changes to the linker, just a move of the
dynobj test in bfd_elf_size_dynamic_sections to target backend
functions, replacing the asserts/aborts already there.  No doubt some
of the current always_size_sections functions could be moved to
size_dynamic_sections but I haven't made that change.

Because both hooks are now always called, I have renamed
always_size_sections to early_size_sections and size_dynamic_sections
to late_size_sections.  I condisdered calling late_size_sections plain
size_sections, since this is the usual target dynamic section sizing
hook, but decided that searching the sources for "size_sections" would
then hit early_size_sections and other functions.
2024-04-02 10:32:04 +10:30
Alan Modra
fd67aa1129 Update year range in copyright notice of binutils files
Adds two new external authors to etc/update-copyright.py to cover
bfd/ax_tls.m4, and adds gprofng to dirs handled automatically, then
updates copyright messages as follows:

1) Update cgen/utils.scm emitted copyrights.
2) Run "etc/update-copyright.py --this-year" with an extra external
   author I haven't committed, 'Kalray SA.', to cover gas testsuite
   files (which should have their copyright message removed).
3) Build with --enable-maintainer-mode --enable-cgen-maint=yes.
4) Check out */po/*.pot which we don't update frequently.
2024-01-04 22:58:12 +10:30
H.J. Lu
832ca732b8 x86-64: Add -z mark-plt and -z nomark-plt
The PLT entry in executables and shared libraries contains an indirect
branch, like

 	jmp *foo@GOTPCREL(%rip)
	push $index_foo
	jmp .PLT0

or

	endbr64
 	jmp *foo@GOTPCREL(%rip)
 	NOP padding

which is used to branch to the function, foo, defined in another object.
Each R_X86_64_JUMP_SLOT relocation has a corresponding PLT entry.

The dynamic tags have been added to the x86-64 psABI to mark such PLT
entries:

6d824a52a4

Add an x86-64 linker option, -z mark-plt, to mark PLT entries with

 #define DT_X86_64_PLT     (DT_LOPROC + 0)
 #define DT_X86_64_PLTSZ   (DT_LOPROC + 1)
 #define DT_X86_64_PLTENT  (DT_LOPROC + 3)

1. DT_X86_64_PLT: The address of the procedure linkage table.
2. DT_X86_64_PLTSZ: The total size, in bytes, of the procedure linkage
table.
3. DT_X86_64_PLTENT: The size, in bytes, of a procedure linkage table
entry.

and set the r_addend field of the R_X86_64_JUMP_SLOT relocation to the
memory offset of the indirect branch instruction.  The dynamic linker
can use these tags to update the PLT section to direct branch.

bfd/

	* elf-linker-x86.h (elf_linker_x86_params): Add mark_plt.
	* elf64-x86-64.c (elf_x86_64_finish_dynamic_symbol): Set the
	r_addend of R_X86_64_JUMP_SLOT to the indirect branch offset
	in PLT entry for -z mark-plt.
	* elfxx-x86.c (_bfd_x86_elf_size_dynamic_sections): Add
	DT_X86_64_PLT, DT_X86_64_PLTSZ and DT_X86_64_PLTENT for
	-z mark-plt.
	(_bfd_x86_elf_finish_dynamic_sections): Set DT_X86_64_PLT,
	DT_X86_64_PLTSZ and DT_X86_64_PLTENT.
	(_bfd_x86_elf_get_synthetic_symtab): Ignore addend for
	JUMP_SLOT relocation.
	(_bfd_x86_elf_link_setup_gnu_properties): Set
	plt_indirect_branch_offset.
	* elfxx-x86.h (elf_x86_plt_layout): Add plt_indirect_branch_offset.

binutils/

	* readelf.c (get_x86_64_dynamic_type): New function.
	(get_dynamic_type): Call get_x86_64_dynamic_type.

include/

	* elf/x86-64.h (DT_X86_64_PLT): New.
	(DT_X86_64_PLTSZ): Likewise.
	(DT_X86_64_PLTENT): Likewise.

ld/

	* ld.texi: Document -z mark-plt and -z nomark-plt.
	* emulparams/elf32_x86_64.sh: Source x86-64-plt.sh.
	* emulparams/elf_x86_64.sh: Likewise.
	* emulparams/x86-64-plt.sh: New file.
	* testsuite/ld-x86-64/mark-plt-1.s: Likewise.
	* testsuite/ld-x86-64/mark-plt-1a-x32.d: Likewise.
	* testsuite/ld-x86-64/mark-plt-1a.d: Likewise.
	* testsuite/ld-x86-64/mark-plt-1b-x32.d: Likewise.
	* testsuite/ld-x86-64/mark-plt-1b.d: Likewise.
	* testsuite/ld-x86-64/mark-plt-1c-x32.d: Likewise.
	* testsuite/ld-x86-64/mark-plt-1c.d: Likewise.
	* testsuite/ld-x86-64/mark-plt-1d-x32.d: Likewise.
	* testsuite/ld-x86-64/mark-plt-1d.d: Likewise.
	* testsuite/ld-x86-64/x86-64.exp: Run -z mark-plt tests.
2023-09-29 07:58:53 -07:00
Peter Edwards
fa4f2d46f9 x86: Fix DT_JMPREL/DT_PLTRELSZ when relocs share a section
If a linker script does not place the PLT relocations and "normal"
relocations in separate ELF sections, `ld` will currently output incorrect
values for DT_JMPREL and DT_PLTRELSZ - they cover the entire ELF section,
rather than just the PLT relocations

Don't ignore the extent of the BFD section - use the size of the srelplt
BFD section and its offset from the output_secttion

bfd/

	PR ld/30787
	* elfxx-x86.c (_bfd_x86_elf_finish_dynamic_sections): Use input
	section for DT_JMPREL and DT_PLTRELSZ.

ld/

	PR ld/30787
	* testsuite/ld-i386/i386.exp: Run pr30787.
	* testsuite/ld-x86-64/x86-64.exp: Likewise.
	* testsuite/ld-i386/pr30787.d: New file.
	* testsuite/ld-i386/pr30787.s: Likewise.
	* testsuite/ld-i386/pr30787.t: Likewise.
	* testsuite/ld-x86-64/pr30787.d: Likewise.
	* testsuite/ld-x86-64/pr30787.s: Likewise.
	* testsuite/ld-x86-64/pr30787.t: Likewise.
2023-08-23 09:10:16 -07:00
Indu Bhagat
ce9a87252c sframe: bfd: gas: ld: format bump to SFrame version 2
SFrame version 2 encodes the size of repetitive insn block explicitly
in the format.  Add information in the SFrame FDE to convey the size
of the block of repeating instructions.  This information is used only
for SFrame FDEs of type SFRAME_FDE_TYPE_PCMASK.

Introduce two extra bytes for padding: this ensures that the memory
accesses to the members of the SFrame Frame Descriptor Entry (FDE) are
naturally aligned.

gas generates SFrame section with version SFRAME_VERSION_2 by default.

libsframe provides two new APIs to:
  - get an SFrame FDE data from the decoder context, and
  - add an SFrame FDE to the encoder context.
The additional argument (for rep_block_size) is useful for SFrame FDEs
where FDE type is SFRAME_FDE_TYPE_PCMASK.

The linker will generate the output SFrame sections in the
SFRAME_VERSION_2 format.  If the input sections offered to the linker
are not all in the SFRAME_VERSION_2 format, the linker issues an error
to the user.

objdump/readelf will show the following message to the user if .sframe
section in SFRAME_VERSION_1 format is seen:

 "No further information can be displayed.  SFrame version not
 supported."

In other words, like the rest of the binutils, only the current SFrame
format version, i.e., SFRAME_VERSION_2 is supported by the textual dump
facilities.

bfd/
	* elf-sframe.c (_bfd_elf_merge_section_sframe): Generate an
	output SFrame section with version SFRAME_VERSION_2.  Also,
	error out if the SFrame sections do not all have
	SFRAME_VERSION_2.
	* elfxx-x86.c (_bfd_x86_elf_create_sframe_plt): Generate SFrame
	section for plt entries with version SFRAME_VERSION_2.
gas/
	* gen-sframe.c (sframe_set_version): Update to SFRAME_VERSION_2.
	(output_sframe): Likewise.
gas/testsuite/
	* gas/cfi-sframe/cfi-sframe-aarch64-1.d: Use SFRAME_VERSION_2.
	* gas/cfi-sframe/cfi-sframe-aarch64-2.d: Likewise.
	* gas/cfi-sframe/cfi-sframe-aarch64-pac-ab-key-1.d: Likewise.
	* gas/cfi-sframe/cfi-sframe-common-1.d: Likewise.
	* gas/cfi-sframe/cfi-sframe-common-2.d: Likewise.
	* gas/cfi-sframe/cfi-sframe-common-3.d: Likewise.
	* gas/cfi-sframe/cfi-sframe-common-4.d: Likewise.
	* gas/cfi-sframe/cfi-sframe-common-5.d: Likewise.
	* gas/cfi-sframe/cfi-sframe-common-6.d: Likewise.
	* gas/cfi-sframe/cfi-sframe-common-7.d: Likewise.
	* gas/cfi-sframe/cfi-sframe-common-8.d: Likewise.
	* gas/cfi-sframe/cfi-sframe-x86_64-1.d: Likewise.
	* gas/cfi-sframe/common-empty-1.d: Likewise.
	* gas/cfi-sframe/common-empty-2.d: Likewise.
	* gas/cfi-sframe/common-empty-3.d: Likewise.
ld/testsuite/
	* ld-aarch64/sframe-simple-1.d: Adjust for SFRAME_VERSION_2.
	* ld-x86-64/sframe-plt-1.d: Likewise.
	* ld-x86-64/sframe-simple-1.d: Likewise.
libsframe/
	* libsframe.ver: Add the new APIs.
	* sframe.c (sframe_decoder_get_funcdesc_v2): New definition.
	(sframe_encoder_add_funcdesc_v2): Likewise.
	(sframe_header_sanity_check_p): Include SFRAME_VERSION_2.
	(sframe_fre_check_range_p): Get rep_block_size info from SFrame
	FDE.
	* sframe-dump.c (dump_sframe_header): Add support for
	SFRAME_VERSION_2.
	(dump_sframe): Inform user if SFrame section in SFRAME_VERSION_1
	format is seen.
libsframe/testsuite/
	* libsframe.decode/DATA-BE: Regenerated data file.
	* libsframe.decode/DATA1: Likewise.
	* libsframe.decode/DATA2: Likewise.
	* libsframe.find/plt-findfre-1.c: Use new API in the testcase.
include/
	* sframe.h: Add member to encode size of the code block of
	repeating instructions.  Add 2 bytes of padding.
	* sframe-api.h (sframe_decoder_get_funcdesc_v2): New
	declaration.
	(sframe_encoder_add_funcdesc_v2): Likewise.
2023-06-29 16:31:58 -07:00
Indu Bhagat
49e4485cba libsframe: bfd: use uint32_t for return type of sframe_calc_fre_type
Use uint32_t type alias consistently for all APIs in libsframe.

bfd/
	* elfxx-x86.c (_bfd_x86_elf_create_sframe_plt): Adjust for the
	changed return type.
libsframe/
	* sframe.c (sframe_calc_fre_type): Use uint32_t for return type.
include/
	* sframe-api.h (sframe_calc_fre_type): Likewise.
2023-06-27 12:01:56 -07:00
H.J. Lu
d8bcb87236 x86: Free the symbol buffer and the relocation buffer after use
When --no-keep-memory is used, the symbol buffer and the relocation
buffer aren't cached.  When packing relative relocations, we may
allocate a new symbol buffer and a new relocation buffer for each
eligible section in an object file.  If there are many sections,
memory may be exhausted.  In this case, we should free the symbol
buffer and the relocation buffer after use.  If symbol buffer entries
are used to track relative relocations against local symbols for later
use, the symbol buffer should be cached.

	PR ld/30566
	* elfxx-x86.c (elf_x86_relative_reloc_record_add): Add an
	argument to inform caller if the symbol buffer should be kept.
	(_bfd_x86_elf_link_relax_section): Call
	_bfd_elf_link_info_read_relocs instead of
	_bfd_elf_link_read_relocs.  Free the symbol buffer and the
	relocation buffer after use.  Cache the symbol buffer if it
	is used.
2023-06-21 09:13:34 -07:00
Indu Bhagat
53d8d3f0c1 bfd: use "stack trace" instead of "unwind" for SFrame
SFrame format is meant for generating stack traces only.

bfd/
	* elf-bfd.h: Replace the use of "unwind" with "stack trace".
	* elf-sframe.c: Likewise.
	* elf64-x86-64.c: Likewise.
	* elfxx-x86.c: Likewise.

include/
	* elf/common.h: Likewise.
2023-02-02 00:49:29 -08:00
Alan Modra
d87bef3a7b Update year range in copyright notice of binutils files
The newer update-copyright.py fixes file encoding too, removing cr/lf
on binutils/bfdtest2.c and ld/testsuite/ld-cygwin/exe-export.exp, and
embedded cr in binutils/testsuite/binutils-all/ar.exp string match.
2023-01-01 21:50:11 +10:30
H.J. Lu
9eb71a53bf x86-64: Allocate input section memory if needed
When --no-keep-memory is used, the input section memory may not be cached.
Allocate input section memory for -z pack-relative-relocs if needed.

bfd/

	PR ld/29939
	* elfxx-x86.c (elf_x86_size_or_finish_relative_reloc): Allocate
	input section memory if needed.

ld/

	PR ld/29939
	* testsuite/ld-elf/dt-relr-2i.d: New test.
2022-12-27 11:46:30 -08:00
Martin Liska
8ad93045ed ld, gold: remove support for -z bndplt (MPX prefix)
bfd/ChangeLog:

	* elf-linker-x86.h (struct elf_linker_x86_params): Remove
	bndplt.
	* elf64-x86-64.c (elf_x86_64_scan_relocs): Ignore
        R_X86_64_PLT32_BND.
	(elf_x86_64_relocate_section): Similarly here.
	(elf_x86_64_link_setup_gnu_properties): Ignore bndplt.
	* elfxx-x86.c: Likewise.
	* elfxx-x86.h: Likewise.

gold/ChangeLog:

	* NEWS: Document -z bndplt.
	* options.h (class General_options): Remove bndplt option.
	* x86_64.cc (class Output_data_plt_x86_64_bnd): Remove.
	(Target_x86_64::do_make_data_plt): Do not use
	Output_data_plt_x86_64_bnd.
	(Target_x86_64::Scan::get_reference_flags): Likewise.
	(Target_x86_64::Scan::check_non_pic): Likewise.
	(Target_x86_64::Scan::local): Likewise.
	(Target_x86_64::Scan::global): Likewise.

ld/ChangeLog:

	* NEWS: Document -z bndplt.
	* emulparams/elf_x86_64.sh: Remove bndplt option.
	* ld.texi: Likewise.
	* testsuite/ld-x86-64/x86-64.exp:
	* testsuite/ld-x86-64/bnd-branch-1-now.d: Removed.
	* testsuite/ld-x86-64/bnd-branch-1.d: Removed.
	* testsuite/ld-x86-64/bnd-branch-1.s: Removed.
	* testsuite/ld-x86-64/bnd-ifunc-1-now.d: Removed.
	* testsuite/ld-x86-64/bnd-ifunc-1.d: Removed.
	* testsuite/ld-x86-64/bnd-ifunc-1.s: Removed.
	* testsuite/ld-x86-64/bnd-ifunc-2-now.d: Removed.
	* testsuite/ld-x86-64/bnd-ifunc-2.d: Removed.
	* testsuite/ld-x86-64/bnd-ifunc-2.s: Removed.
	* testsuite/ld-x86-64/bnd-plt-1-now.d: Removed.
	* testsuite/ld-x86-64/bnd-plt-1.d: Removed.
	* testsuite/ld-x86-64/mpx.exp: Removed.
	* testsuite/ld-x86-64/mpx1.out: Removed.
	* testsuite/ld-x86-64/mpx1a.c: Removed.
	* testsuite/ld-x86-64/mpx1a.rd: Removed.
	* testsuite/ld-x86-64/mpx1b.c: Removed.
	* testsuite/ld-x86-64/mpx1c.c: Removed.
	* testsuite/ld-x86-64/mpx1c.rd: Removed.
	* testsuite/ld-x86-64/mpx2.out: Removed.
	* testsuite/ld-x86-64/mpx2a.c: Removed.
	* testsuite/ld-x86-64/mpx2a.rd: Removed.
	* testsuite/ld-x86-64/mpx2b.c: Removed.
	* testsuite/ld-x86-64/mpx2c.c: Removed.
	* testsuite/ld-x86-64/mpx2c.rd: Removed.
	* testsuite/ld-x86-64/mpx3.dd: Removed.
	* testsuite/ld-x86-64/mpx3a.s: Removed.
	* testsuite/ld-x86-64/mpx3b.s: Removed.
	* testsuite/ld-x86-64/mpx3n.dd: Removed.
	* testsuite/ld-x86-64/mpx4.dd: Removed.
	* testsuite/ld-x86-64/mpx4a.s: Removed.
	* testsuite/ld-x86-64/mpx4b.s: Removed.
	* testsuite/ld-x86-64/mpx4n.dd: Removed.
	* testsuite/ld-x86-64/pr20800a.S: Removed.
	* testsuite/ld-x86-64/pr20800b.S: Removed.
	* testsuite/ld-x86-64/pr21038a-now.d: Removed.
	* testsuite/ld-x86-64/pr21038a.d: Removed.
	* testsuite/ld-x86-64/pr21038a.s: Removed.
	* testsuite/ld-x86-64/pr21038b-now.d: Removed.
	* testsuite/ld-x86-64/pr21038b.d: Removed.
	* testsuite/ld-x86-64/pr21038b.s: Removed.
	* testsuite/ld-x86-64/pr21038c-now.d: Removed.
	* testsuite/ld-x86-64/pr21038c.d: Removed.
	* testsuite/ld-x86-64/pr21038c.s: Removed.
2022-12-14 08:48:13 +01:00
Indu Bhagat
b659fb3585 libsframe: rename API sframe_fde_func_info to sframe_fde_create_func_info
The new name better reflects the purpose of the function.

ChangeLog:

	* bfd/elfxx-x86.c (_bfd_x86_elf_create_sframe_plt): Use new
	name.
	* libsframe/sframe.c (sframe_fde_create_func_info): Rename
	sframe_fde_func_info to this.
	* libsframe/testsuite/libsframe.encode/encode-1.c: Use new name.

include/ChangeLog:

	* sframe-api.h (sframe_fde_create_func_info): Rename
	sframe_fde_func_info to this.
2022-12-09 10:25:31 -08:00
H.J. Lu
04ad71937f x86: Don't define _TLS_MODULE_BASE_ for ld -r
bfd/

	PR ld/29820
	* elfxx-x86.c (_bfd_x86_elf_always_size_sections): Don't define
	 _TLS_MODULE_BASE_ for ld -r.

ld/

	PR ld/29820
	* testsuite/ld-x86-64/pr29820.d: New file.
	* testsuite/ld-x86-64/pr29820.s: Likewise.
	* testsuite/ld-x86-64/x86-64.ex: Run pr29820.
2022-11-22 14:03:16 -08:00
Indu Bhagat
cf0e0a0ba9 bfd: linker: merge .sframe sections
The linker merges all the input .sframe sections.  When merging, the
linker verifies that all the input .sframe sections have the same
abi/arch.

The linker uses libsframe library to perform key actions on the
.sframe sections - decode, read, and create output data.  This
implies buildsystem changes to make and install libsframe before
libbfd.

The linker places the output .sframe section in a new segment of its
own: PT_GNU_SFRAME.  A new segment is not added, however, if the
generated .sframe section is empty.

When a section is discarded from the final link, the corresponding
entries in the .sframe section for those functions are also deleted.

The linker sorts the SFrame FDEs on start address by default and sets
the SFRAME_F_FDE_SORTED flag in the .sframe section.

This patch also adds support for generation of SFrame unwind
information for the .plt* sections on x86_64.  SFrame unwind info is
generated for IBT enabled PLT, lazy/non-lazy PLT.

The existing linker option --no-ld-generated-unwind-info has been
adapted to include the control of whether .sframe unwind information
will be generated for the linker generated sections like PLT.

Changes to the linker script have been made as necessary.

ChangeLog:

	* Makefile.def: Add install dependency on libsframe for libbfd.
	* Makefile.in: Regenerated.
	* bfd/Makefile.am: Add elf-sframe.c
	* bfd/Makefile.in: Regenerated.
	* bfd/bfd-in2.h (SEC_INFO_TYPE_SFRAME): Regenerated.
	* bfd/configure: Regenerate.
	* bfd/configure.ac: Add elf-sframe.lo.
	* bfd/elf-bfd.h (struct sframe_func_bfdinfo): New struct.
	(struct sframe_dec_info): Likewise.
	(struct sframe_enc_info): Likewise.
	(struct elf_link_hash_table): New member for encoded .sframe
	object.
	(struct output_elf_obj_tdata): New member.
	(elf_sframe): New access macro.
	(_bfd_elf_set_section_sframe): New declaration.
	* bfd/elf.c (get_segment_type): Handle new segment
	PT_GNU_SFRAME.
	(bfd_section_from_phdr): Likewise.
	(get_program_header_size): Likewise.
	(_bfd_elf_map_sections_to_segments): Likewise.
	* bfd/elf64-x86-64.c (elf_x86_64_link_setup_gnu_properties): Add
	contents to the .sframe sections or .plt* entries.
	* bfd/elflink.c (elf_section_ignore_discarded_relocs): Handle
	SEC_INFO_TYPE_SFRAME.
	(_bfd_elf_default_action_discarded): Handle .sframe section.
	(elf_link_input_bfd): Merge .sframe section.
	(bfd_elf_final_link): Write the output .sframe section.
	(bfd_elf_discard_info): Handle discarding .sframe section.
	* bfd/elfxx-x86.c (_bfd_x86_elf_size_dynamic_sections): Create
	.sframe section for .plt and .plt.sec.
	(_bfd_x86_elf_finish_dynamic_sections): Handle .sframe from
	.plt* sections.
	* bfd/elfxx-x86.h (PLT_SFRAME_FDE_START_OFFSET): New
	definition.
	(SFRAME_PLT0_MAX_NUM_FRES): Likewise.
	(SFRAME_PLTN_MAX_NUM_FRES): Likewise.
	(struct elf_x86_sframe_plt): New structure.
	(struct elf_x86_link_hash_table): New member.
	(struct elf_x86_init_table): New members for .sframe
	creation.
	* bfd/section.c: Add new definition SEC_INFO_TYPE_SFRAME.
	* binutils/readelf.c (get_segment_type): Handle new segment
	PT_GNU_SFRAME.
	* ld/ld.texi: Update documentation for
	--no-ld-generated-unwind-info.
	* ld/scripttempl/elf.sc: Support .sframe sections.
	* ld/Makefile.am (TESTSFRAMELIB): Use it.
	(check-DEJAGNU): Likewise.
	* ld/Makefile.in: Regenerated.
	* ld/configure.ac (TESTSFRAMELIB): Set to the .so or .a like TESTBFDLIB.
	* ld/configure: Regenerated.
	* bfd/elf-sframe.c: New file.

include/ChangeLog:

	* elf/common.h (PT_GNU_SFRAME): New definition.
	* elf/internal.h (struct elf_segment_map): Handle new segment
	type PT_GNU_SFRAME.

ld/testsuite/ChangeLog:

	* ld/testsuite/ld-bootstrap/bootstrap.exp: Add SFRAMELIB.
	* ld/testsuite/ld-aarch64/aarch64-elf.exp: Add new test
	  sframe-simple-1.
	* ld/testsuite/ld-aarch64/sframe-bar.s: New file.
	* ld/testsuite/ld-aarch64/sframe-foo.s: Likewise.
	* ld/testsuite/ld-aarch64/sframe-simple-1.d: Likewise.
	* ld/testsuite/ld-sframe/sframe-empty.d: New test.
	* ld/testsuite/ld-sframe/sframe-empty.s: New file.
	* ld/testsuite/ld-sframe/sframe.exp: New testsuite.
	* ld/testsuite/ld-x86-64/sframe-bar.s: New file.
	* ld/testsuite/ld-x86-64/sframe-foo.s: Likewise.
	* ld/testsuite/ld-x86-64/sframe-simple-1.d: Likewise.
	* ld/testsuite/ld-x86-64/sframe-plt-1.d: Likewise.
	* ld/testsuite/ld-x86-64/sframe-simple-1.d: Likewise.
	* ld/testsuite/ld-x86-64/x86-64.exp: Add new tests -
	  sframe-simple-1, sframe-plt-1.
	* ld/testsuite/lib/ld-lib.exp: Add new proc to check if
	  assembler supports SFrame section.
	* ld/testsuite/ld-sframe/discard.d: New file.
	* ld/testsuite/ld-sframe/discard.ld: Likewise.
	* ld/testsuite/ld-sframe/discard.s: Likewise.
2022-11-15 15:49:47 -08:00
H.J. Lu
f638657759 x86: Disallow invalid relocations against protected symbols
Since glibc 2.36 will issue warnings for copy relocation against
protected symbols and non-canonical reference to canonical protected
functions, change the linker to always disallow such relocations.

bfd/

	* elf32-i386.c (elf_i386_scan_relocs): Remove check for
	elf_has_indirect_extern_access.
	* elf64-x86-64.c (elf_x86_64_scan_relocs): Likewise.
	(elf_x86_64_relocate_section): Remove check for
	elf_has_no_copy_on_protected.
	* elfxx-x86.c (elf_x86_allocate_dynrelocs): Check for building
	executable instead of elf_has_no_copy_on_protected.
	(_bfd_x86_elf_adjust_dynamic_symbol): Disallow copy relocation
	against non-copyable protected symbol.
	* elfxx-x86.h (SYMBOL_NO_COPYRELOC): Remove check for
	elf_has_no_copy_on_protected.

ld/

	* testsuite/ld-i386/i386.exp: Expect linker error for PR ld/17709
	test.
	* testsuite/ld-i386/pr17709.rd: Removed.
	* testsuite/ld-i386/pr17709.err: New file.
	* testsuite/ld-x86-64/pr17709.rd: Removed.
	* testsuite/ld-x86-64/pr17709.err: New file.
	* testsuite/ld-x86-64/pr28875-func.err: Updated.
	* testsuite/ld-x86-64/x86-64.exp: Expect linker error for PR
	ld/17709 test.  Add tests for function pointer against protected
	function.
2022-07-19 08:41:52 -07:00
Fangrui Song
d19a265487 x86: Make protected symbols local for -shared
Call _bfd_elf_symbol_refs_local_p with local_protected==true.  This has
2 noticeable effects for -shared:

* GOT-generating relocations referencing a protected data symbol no
  longer lead to a GLOB_DAT (similar to a hidden symbol).
* Direct access relocations (e.g. R_X86_64_PC32) no longer has the
  confusing diagnostic below.

    __attribute__((visibility("protected"))) void *foo() {
      return (void *)foo;
    }

    // gcc -fpic -shared -fuse-ld=bfd
    relocation R_X86_64_PC32 against protected symbol `foo' can not be used when making a shared object

The new behavior matches arm, aarch64 (commit
83c325007c), and powerpc ports, and other
linkers: gold and ld.lld.

Note: if some code tries to use direct access relocations to take the
address of foo, the pointer equality will break, but the error should be
reported on the executable link, not on the innocent shared object link.
glibc 2.36 will give a warning at relocation resolving time.

With this change, `#define elf_backend_extern_protected_data 1` is no
longer effective.  Just remove it.

Remove the test "Run protected-func-1 without PIE" since -fno-pic
address taken operation in the executable doesn't work with protected
symbol in a shared object by default.  Similarly, remove
protected-data-1a and protected-data-1b.  protected-data-1b can be made
working by removing HAVE_LD_PIE_COPYRELOC from GCC
(https://sourceware.org/pipermail/gcc-patches/2022-June/596678.html).
2022-07-19 08:41:52 -07:00
H.J. Lu
ebb191adac x86: Disallow invalid relocation against protected symbol
I am checking this into master and will backport it to 2.38 branch.

H.J
----
On x86, GCC 12 supports -mno-direct-extern-access to enable canonical
reference to protected function and disable copy relocation.  With
-mno-direct-extern-access, the canonical protected function symbols must
be accessed via canonical reference and the protected data symbols in
shared libraries are non-copyable. Under glibc 2.35, non-canonical
reference to the canonical protected function will get the run-time error:

./y: internal_f: ./libfoo.so: non-canonical reference to canonical protected function

and copy relocations against the non-copyable protected symbols will get
the run-time error:

./x: internal_i: ./libfoo.so: copy relocation against non-copyable protected symbol

Update x86 linker to disallow non-canonical reference to the canonical
protected function:

ld: plt.o: non-canonical reference to canonical protected function `internal_f' in libfoo.so
ld: failed to set dynamic section sizes: bad value

and copy relocation against the non-copyable protected symbol:

ld: main.o: copy relocation against non-copyable protected symbol `internal_i' in libfoo.so

at link-time.

bfd/

	PR ld/28875
	* elf-properties.c (_bfd_elf_parse_gnu_properties): Don't skip
	shared libraries for GNU_PROPERTY_1_NEEDED_INDIRECT_EXTERN_ACCESS.
	* elf32-i386.c (elf_i386_scan_relocs): Disallow non-canonical
	reference to canonical protected function.
	* elf64-x86-64.c (elf_x86_64_scan_relocs): Likewise.
	* elfxx-x86.c (elf_x86_allocate_dynrelocs): Don't allow copy
	relocation against non-copyable protected symbol.

ld/

	PR ld/28875
	* testsuite/ld-i386/i386.exp: Check non-canonical reference to
	canonical protected function and check copy relocation against
	non-copyable protected symbol.
	* testsuite/ld-i386/pr21997-1.err: New file.
	* testsuite/ld-i386/pr28875.err: Likewise.
	* testsuite/ld-i386/pr28875a.c: Likewise.
	* testsuite/ld-i386/pr28875b.c: Likewise.
	* testsuite/ld-x86-64/pr21997-1a.err: Updated.
	* testsuite/ld-x86-64/pr21997-1b.err: Likewise.
	* testsuite/ld-x86-64/pr28875-data.err: New file.
	* testsuite/ld-x86-64/pr28875-func.err: Likewise.
	* testsuite/ld-x86-64/x86-64.exp: Check non-canonical reference
	to canonical protected function and check copy relocation against
	non-copyable protected symbol.
2022-02-11 10:24:54 -08:00
H.J. Lu
30a954525f i386: Allow GOT32 relocations against ABS symbols
GOT32 relocations are allowed since absolute value + addend is stored in
the GOT slot.

Tested on glibc 2.35 build with GCC 11.2 and -Os.

bfd/

	PR ld/28870
	* elfxx-x86.c (_bfd_elf_x86_valid_reloc_p): Also allow GOT32
	relocations.

ld/

	PR ld/28870
	* testsuite/ld-i386/i386.exp: Run pr28870.
	* testsuite/ld-i386/pr28870.d: New file.
	* testsuite/ld-i386/pr28870.s: Likewise.
2022-02-07 16:04:10 -08:00
H.J. Lu
a9e61227c0 x86: Skip undefined symbol when finishing DT_RELR
Don't abort for undefined symbol when finishing DT_RELR.  Instead, skip
undefined symbol.  Undefined symbol will be reported by relocate_section.

	* elfxx-x86.c (elf_x86_size_or_finish_relative_reloc): Skip
	undefined symbol in finishing phase.
2022-02-05 07:34:12 -08:00
Alan Modra
9c3d7d9b7e Move DT_RELR tag setting to elflink.c
This makes the code setting DT_RELR tags generally available.  Many
targets will be able to use the defaults.  Those that can't should set
up sh_entsize for .relr.dyn output section before reaching the dynamic
tag code in bfd_elf_final_link.

	* elflink.c (bfd_elf_final_link): Set up DT_RELR tags and sh_entsize.
	* elfxx-x86.c (_bfd_x86_elf_finish_dynamic_sections): Don't do any
	of that here.
2022-01-13 14:12:43 +10:30
H.J. Lu
5af6f000d8 x86: Add DT_RELR support
DT_RELR is implemented with linker relaxation:

1. During linker relaxation, we scan input relocations with the same
logic in relocate_section to determine if a relative relocation should
be generated and save the relative relocation candidate information for
sizing the DT_RELR section later after all symbols addresses can be
determined.  For these relative relocations which can't be placed in
the DT_RELR section, they will be placed in the rela.dyn/rel.dyn
section.
2. When DT_RELR is enabled, _bfd_elf_map_sections_to_segments calls a
backend function to size the DT_RELR section which will compute the
DT_RELR section size and tell ldelf_map_segments to layout sections
again when the DT_RELR section size has been increased.
3. After regular symbol processing is finished, bfd_elf_final_link calls
a backend function to finish the DT_RELR section.

	* elf32-i386.c (elf_i386_relocate_section): Don't generate
	relative relocation when DT_RELR is enabled.
	(elf_i386_finish_dynamic_symbol): Likewise.
	* elf64-x86-64.c (elf_x86_64_relocate_section): Don't generate
	relative relocation when DT_RELR is enabled.
	(elf_x86_64_finish_dynamic_symbol): Likewise.
	* elfxx-x86.c (_bfd_x86_elf_link_hash_table_create): Initialize
	relative_r_type, relative_r_name, elf_append_reloc,
	elf_write_addend and elf_write_addend_in_got.
	(elf_x86_relative_reloc_record_add): New function.
	(_bfd_x86_elf_link_relax_section): Likewise.
	(elf64_dt_relr_bitmap_add): Likewise.
	(elf32_dt_relr_bitmap_add): Likewise.
	(_bfd_elf32_write_addend): Likewise.
	(_bfd_elf64_write_addend): Likewise.
	(elf_x86_size_or_finish_relative_reloc): Likewise.
	(elf_x86_compute_dl_relr_bitmap): Likewise.
	(elf_x86_write_dl_relr_bitmap): Likewise.
	(elf_x86_relative_reloc_compare ): Likewise.
	(_bfd_elf_x86_size_relative_relocs): Likewise.
	(_bfd_elf_x86_finish_relative_relocs): Likewise.
	(_bfd_x86_elf_size_dynamic_sections): Skip the .relr.dyn section.
	(_bfd_x86_elf_finish_dynamic_sections): Convert 3 spare dynamic
	tags to DT_RELR, DT_RELRSZ and for compact relative relocation.
	* elfxx-x86.h (X86_64_GOT_TYPE_P): New.
	(I386_GOT_TYPE_P): Likewise.
	(X86_GOT_TYPE_P): Likewise.
	(X86_64_RELATIVE_RELOC_TYPE_P): Likewise.
	(I386_RELATIVE_RELOC_TYPE_P): Likewise.
	(X86_RELATIVE_RELOC_TYPE_P): Likewise.
	(X86_LOCAL_GOT_RELATIVE_RELOC_P): Likewise.
	(I386_PCREL_TYPE_P): Likewise.
	(X86_64_PCREL_TYPE_P): Likewise.
	(X86_64_NEED_DYNAMIC_RELOC_TYPE_P): Rewrite.
	(I386_NEED_DYNAMIC_RELOC_TYPE_P): Likewise.
	(GENERATE_DYNAMIC_RELOCATION_P): Also check rel_from_abs.
	(elf_x86_link_hash_entry): Add got_relative_reloc_done.
	(elf_x86_relative_reloc_record): New.
	(elf_x86_relative_reloc_data): Likewise.
	(elf_dt_relr_bitmap): Likewise.
	(elf_x86_link_hash_table): Add dt_relr_bitmap, relative_reloc,
	unaligned_relative_reloc, relative_r_type, relative_r_name,
	elf_append_reloc, elf_write_addend, elf_write_addend_in_got and
	relative_reloc_done.
	(elf_x86_relative_reloc_done): New.
	(relative_reloc_packed): Likewise.
	(_bfd_x86_elf_link_relax_section): Likewise.
	(_bfd_elf_x86_size_relative_relocs): Likewise.
	(_bfd_elf_x86_finish_relative_relocs): Likewise.
	(_bfd_elf32_write_addend): Likewise.
	(_bfd_elf64_write_addend): Likewise.
	(bfd_elf32_bfd_relax_section): Likewise.
	(bfd_elf64_bfd_relax_section): Likewise.
	(elf_backend_size_relative_relocs): Likewise.
	(elf_backend_finish_relative_relocs): Likewise.
	(elf_x86_allocate_local_got_info): Also allocate
	relative_reloc_done.
2022-01-12 06:04:51 -08:00
H.J. Lu
3747999c6b ld: Extract _bfd_elf_link_iterate_on_relocs
DT_RELR encodes consecutive R_*_RELATIVE relocations in GOT (the global
offset table) and data sections in a compact format:

https://groups.google.com/g/generic-abi/c/bX460iggiKg

On some targets, R_*_RELATIVE relocations are counted and the GOT offsets
are allocated when setting the dynamic section sizes after seeing all
relocations.  R_*_RELATIVE relocations are generated while relocating
sections after section layout has been finalized.

To prepare for DT_RELR implementation on these targets, extract
_bfd_elf_link_iterate_on_relocs from _bfd_elf_link_check_relocs so
that a backend can scan relocations in elf_backend_always_size_sections

For x86 targets, the old check_relocs is renamed to scan_relocs and a
new check_relocs is added to chek input sections and create dynamic
relocation sections so that they will be mapped to output sections.
scan_relocs is now called from elf_backend_always_size_sections.

Since relocations are scanned after __start, __stop, .startof. and
.sizeof. symbols have been finalized on x86, __[start|stop]_SECNAME for
--gc-sections -z start-stop-gc are now zero when all SECNAME sections
been garbage collected.  This is no need for elf_x86_start_stop_gc_p.

bfd/

	* elf-bfd.h (_bfd_elf_link_iterate_on_relocs): New.
	* elf32-i386.c (elf_i386_convert_load_reloc): Don't call
	elf_x86_start_stop_gc_p.
	(elf_i386_check_relocs): Renamed to ...
	(elf_i386_scan_relocs): This.  Don't call
	_bfd_elf_make_dynamic_reloc_section.
	(elf_i386_always_size_sections): New.
	(elf_backend_check_relocs): Removed.
	(elf_backend_always_size_sections): New.
	* elf64-x86-64.c (elf_x86_64_convert_load_reloc): Don't call
	elf_x86_start_stop_gc_p.
	(elf_x86_64_check_relocs): Renamed to ...
	(elf_x86_64_scan_relocs): This.  Don't call
	_bfd_elf_make_dynamic_reloc_section.
	(elf_x86_64_always_size_sections): New.
	(elf_backend_check_relocs): Removed.
	(elf_backend_always_size_sections): New.
	* elflink.c (elf_link_check_or_scan_relocs):
	New.  Extracted from _bfd_elf_link_check_relocs.
	(_bfd_elf_link_check_relocs): Call elf_link_check_or_scan_relocs.
	* elfxx-x86.c (_bfd_x86_elf_check_relocs): New.
	* elfxx-x86.h (X86_64_NEED_DYNAMIC_RELOC_TYPE_P): New.
	(I386_NEED_DYNAMIC_RELOC_TYPE_P): Likewise.
	(X86_NEED_DYNAMIC_RELOC_TYPE_P): Likewise.
	(_bfd_x86_elf_check_relocs): Likewise.
	(elf_backend_check_relocs): Likewise.
	(elf_backend_always_size_sections): Removed.
	(elf_x86_start_stop_gc_p): Likewise.

ld/

	* testsuite/ld-i386/pr27491-1a.d: Updated.
	* testsuite/ld-x86-64/pr27491-1a.d: Likewise.
2022-01-07 17:58:20 -08:00
H.J. Lu
7131d475da ld/x86: Update -z report-relative-reloc
Use 0x%v, instead of bfd_sprintf_vma, to report relative relocations.
Change linker relative relocations report from

tmpdir/dump: R_X86_64_IRELATIVE (offset: 0x0000000000002000, info: 0x0000000000000025, addend: 0x0000000000001007) against 'ifunc' for section '.data.rel.ro.local' in tmpdir/report-reloc-1.o

to

tmpdir/dump: R_X86_64_IRELATIVE (offset: 0x2000, info: 0x25, addend: 0x1007) against 'ifunc' for section '.data.rel.ro.local' in tmpdir/report-reloc-1.o

bfd/

	* elfxx-x86.c (_bfd_x86_elf_link_report_relative_reloc): Use
	0x%v instead of bfd_sprintf_vma.

ld/

	* testsuite/ld-i386/report-reloc-1.l: Updated.
	* testsuite/ld-x86-64/report-reloc-1.l: Likewise.
2022-01-04 11:12:01 -08:00
Alan Modra
a2c5833233 Update year range in copyright notice of binutils files
The result of running etc/update-copyright.py --this-year, fixing all
the files whose mode is changed by the script, plus a build with
--enable-maintainer-mode --enable-cgen-maint=yes, then checking
out */po/*.pot which we don't update frequently.

The copy of cgen was with commit d1dd5fcc38ead reverted as that commit
breaks building of bfp opcodes files.
2022-01-02 12:04:28 +10:30
H.J. Lu
831083d300 Define X86_PCREL_TYPE_P/X86_SIZE_TYPE_P in elfxx-x86.h
* elf32-i386.c: Don't include "elf/i386.h".
	(X86_PCREL_TYPE_P): Removed.
	(X86_SIZE_TYPE_P): Likewise.
	(elf_i386_check_relocs): Pass false to NEED_DYNAMIC_RELOCATION_P.
	(elf_i386_relocate_section): Pass false to
	GENERATE_DYNAMIC_RELOCATION_P and COPY_INPUT_RELOC_P.
	* elf64-x86-64.c: Don't include "elf/x86-64.h".
	(X86_PCREL_TYPE_P): Removed.
	(X86_SIZE_TYPE_P): Likewise.
	(elf_x86_64_check_relocs): Pass true to NEED_DYNAMIC_RELOCATION_P
	and X86_PCREL_TYPE_P.
	(elf_x86_64_relocate_section): Pass true to X86_PCREL_TYPE_P,
	X86_SIZE_TYPE_P, GENERATE_DYNAMIC_RELOCATION_P and
	COPY_INPUT_RELOC_P.
	* elfxx-x86.c: Don't include "elf/i386.h" nor "elf/x86-64.h".
	* elfxx-x86.h (X86_64_PCREL_TYPE_P): New.
	(I386_PCREL_TYPE_P): Likewise.
	(X86_PCREL_TYPE_P): Likewise.
	(X86_64_SIZE_TYPE_P): Likewise.
	(I386_SIZE_TYPE_P): Likewise.
	(X86_SIZE_TYPE_P): Likewise.
	(NEED_DYNAMIC_RELOCATION_P): Add IS_X86_64 and pass it to
	X86_PCREL_TYPE_P.
	(COPY_INPUT_RELOC_P): Likewise.
	(GENERATE_DYNAMIC_RELOCATION_P): Add IS_X86_64, pass it to
	X86_PCREL_TYPE_P and X86_SIZE_TYPE_P.
2021-12-31 07:02:41 -08:00
H.J. Lu
6f365fda85 elf: Add GNU_PROPERTY_1_NEEDED check
If GNU_PROPERTY_1_NEEDED_INDIRECT_EXTERN_ACCESS is set on any input
relocatable files:

1. Don't generate copy relocations.
2. Turn off extern_protected_data since it implies
GNU_PROPERTY_NO_COPY_ON_PROTECTED.
3. Treate reference to protected symbols with indirect external access
as local.
4. Set GNU_PROPERTY_1_NEEDED_INDIRECT_EXTERN_ACCESS on output.
5. When generating executable, clear this bit when there are non-GOT or
non-PLT relocations in input relocatable files without the bit set.
6. Add -z [no]indirect-extern-access to control indirect external access.

bfd/

	* elf-bfd (elf_obj_tdata): Add has_indirect_extern_access.
	(elf_has_indirect_extern_access): New.
	* elf-properties.c (_bfd_elf_parse_gnu_properties): Set
	elf_has_indirect_extern_access and elf_has_no_copy_on_protected
	when seeing GNU_PROPERTY_1_NEEDED_INDIRECT_EXTERN_ACCESS.
	(elf_write_gnu_propertie): Add an argument to pass link_info.
	Set needed_1_p for GNU_PROPERTY_1_NEEDED in memory.
	(_bfd_elf_link_setup_gnu_properties): Handle
	GNU_PROPERTY_1_NEEDED_INDIRECT_EXTERN_ACCESS for
	-z indirect-extern-access.  Set nocopyreloc to true and
	extern_protected_data to false for indirect external access.
	(_bfd_elf_convert_gnu_properties): Updated.
	* elf32-i386.c (elf_i386_check_relocs): Set
	non_got_ref_without_indirect_extern_access on legacy non-GOT or
	non-PLT references.
	* elf64-x86-64.c (elf_x86_64_check_relocs): Likewise.
	* elflink.c (_bfd_elf_symbol_refs_local_p): Return true for
	STV_PROTECTED symbols with indirect external access.
	* elfxx-x86.c (_bfd_x86_elf_adjust_dynamic_symbol): Clear
	indirect_extern_access for legacy non-GOT/non-PLT references.
	* elfxx-x86.h (elf_x86_link_hash_entry): Add
	non_got_ref_without_indirect_extern_access.

include/

	* bfdlink.h (bfd_link_info): Add indirect_extern_access and
	needed_1_p.  Change nocopyreloc to int.

ld/

	* NEWS: Mention -z [no]indirect-extern-access
	* ld.texi: Document -z [no]indirect-extern-access
	* ldmain.c (main): Initialize link_info.indirect_extern_access
	to -1.
	* emulparams/extern_protected_data.sh: Support
	-z [no]indirect-extern-access.
	* testsuite/ld-elf/indirect-extern-access-1.rd: New file
	* testsuite/ld-elf/indirect-extern-access-1a.c: Likewise.
	* testsuite/ld-elf/indirect-extern-access-1b.c: Likewise.
	* testsuite/ld-elf/indirect-extern-access-2.rd: Likewise.
	* testsuite/ld-elf/indirect-extern-access-2a.c: Likewise.
	* testsuite/ld-elf/indirect-extern-access-2b.c: Likewise.
	* testsuite/ld-elf/indirect-extern-access-3.rd: Likewise.
	* testsuite/ld-elf/indirect-extern-access.S: Likewise.
	* testsuite/ld-elf/property-1_needed-1b.d: Likewise.
	* testsuite/ld-elf/property-1_needed-1c.d: Likewise.
	* testsuite/ld-x86-64/indirect-extern-access.rd: Likewise.
	* testsuite/ld-x86-64/protected-data-1.h: Likewise.
	* testsuite/ld-x86-64/protected-data-1a.c: Likewise.
	* testsuite/ld-x86-64/protected-data-1b.c: Likewise.
	* testsuite/ld-x86-64/protected-data-2a.S: Likewise.
	* testsuite/ld-x86-64/protected-data-2b.S: Likewise.
	* testsuite/ld-x86-64/protected-func-2a.S: Likewise.
	* testsuite/ld-x86-64/protected-func-2b.S: Likewise.
	* testsuite/ld-x86-64/protected-func-2c.c: Likewise.
	* testsuite/ld-elf/linux-x86.exp: Run test with
	GNU_PROPERTY_1_NEEDED_INDIRECT_EXTERN_ACCESS.
	* testsuite/ld-x86-64/x86-64.exp: Run tests for protected
	function and data with indirect external access.
2021-07-08 18:14:31 -07:00
H.J. Lu
406b4ada55 x86: Count PLT for GOTOFF relocation against IFUNC symbol
Since GOTOFF relocations against IFUNC symbols must go through PLT,
set PLT reference count to 1 for GOTOFF relocation.

bfd/

	PR ld/27998
	* elfxx-x86.c (elf_x86_allocate_dynrelocs): Count PLT for GOTOFF
	relocation against IFUNC symbols.
	(_bfd_x86_elf_adjust_dynamic_symbol): Likewise.

ld/

	PR ld/27998
	* testsuite/ld-i386/i386.exp: Run PR ld/27998 tests.
	* testsuite/ld-i386/pr27998a.d: New file.
	* testsuite/ld-i386/pr27998a.s: Likewise.
	* testsuite/ld-i386/pr27998b.d: Likewise.
	* testsuite/ld-i386/pr27998b.s: Likewise.
2021-06-19 20:21:04 -07:00
H.J. Lu
1273b2f8ac x86: Restore PC16 relocation overflow check
The x86-64 psABI has

---
A program or object file using R_X86_64_8, R_X86_64_16, R_X86_64_PC16
or R_X86_64_PC8 relocations is not conformant to this ABI, these
relocations are only added for documentation purposes.
---

Since x86 PC16 relocations have been used for 16-bit programs in an ELF32
or ELF64 container, PC16 relocation should wrap-around in 16-bit address
space.  Revert

commit a7664973b2
Author: Jan Beulich <jbeulich@suse.com>
Date:   Mon Apr 26 10:41:35 2021 +0200

    x86: correct overflow checking for 16-bit PC-relative relocs

and xfail the related tests.  Also revert

commit 50c95a739c
Author: H.J. Lu <hjl.tools@gmail.com>
Date:   Wed May 26 12:13:13 2021 -0700

    x86: Propery check PC16 reloc overflow in 16-bit mode instructions

while keeping PR ld/27905 tests for PC16 relocation in 16-bit programs.

bfd/

	PR ld/27905
	* elf32-i386.c: Don't include "libiberty.h".
	(elf_howto_table): Revert commits a7664973b2 and 50c95a739c.
	(elf_i386_rtype_to_howto): Revert commit 50c95a739c.
	(elf_i386_info_to_howto_rel): Likewise.
	(elf_i386_tls_transition): Likewise.
	(elf_i386_relocate_section): Likewise.
	* elf64-x86-64.c (x86_64_elf_howto_table): Revert commits
	a7664973b2 and 50c95a739c.
	(elf_x86_64_rtype_to_howto): Revert commit 50c95a739c.
	* elfxx-x86.c (_bfd_x86_elf_parse_gnu_properties): Likewise.
	* elfxx-x86.h (elf_x86_obj_tdata): Likewise.
	(elf_x86_has_code16): Likewise.

binutils/

	PR ld/27905
	* readelf.c (decode_x86_feature_2): Revert commit 50c95a739c.

gas/

	PR ld/27905
	* config/tc-i386.c (set_code_flag): Revert commit 50c95a739c.
	(set_16bit_gcc_code_flag): Likewise.
	(x86_cleanup): Likewise.
	* testsuite/gas/i386/code16-2.d: Updated.
	* testsuite/gas/i386/x86-64-code16-2.d: Likewise.

include/

	PR ld/27905
	* elf/common.h (GNU_PROPERTY_X86_FEATURE_2_CODE16): Removed.

ld/

	PR ld/27905
	* testsuite/ld-i386/pcrel16-2.d: xfail.
	* testsuite/ld-x86-64/pcrel16-2.d: Likewise.
2021-05-28 09:34:28 -07:00
H.J. Lu
50c95a739c x86: Propery check PC16 reloc overflow in 16-bit mode instructions
commit a7664973b2
Author: Jan Beulich <jbeulich@suse.com>
Date:   Mon Apr 26 10:41:35 2021 +0200

    x86: correct overflow checking for 16-bit PC-relative relocs

caused linker failure when building 16-bit program in a 32-bit ELF
container.  Update GNU_PROPERTY_X86_FEATURE_2_USED with

 #define GNU_PROPERTY_X86_FEATURE_2_CODE16 (1U << 12)

to indicate that 16-bit mode instructions are used in the input object:

https://groups.google.com/g/x86-64-abi/c/UvvXWeHIGMA

to indicate that 16-bit mode instructions are used in the object to
allow linker to properly perform relocation overflow check for 16-bit
PC-relative relocations in 16-bit mode instructions.

1. Update x86 assembler to always generate the GNU property note with
GNU_PROPERTY_X86_FEATURE_2_CODE16 for .code16 in ELF object.
2. Update i386 and x86-64 linkers to use 16-bit PC16 relocations if
input object is marked with GNU_PROPERTY_X86_FEATURE_2_CODE16.

bfd/

	PR ld/27905
	* elf32-i386.c: Include "libiberty.h".
	(elf_howto_table): Add 16-bit R_386_PC16 entry.
	(elf_i386_rtype_to_howto): Add a BFD argument.  Use 16-bit
	R_386_PC16 if input has 16-bit mode instructions.
	(elf_i386_info_to_howto_rel): Update elf_i386_rtype_to_howto
	call.
	(elf_i386_tls_transition): Likewise.
	(elf_i386_relocate_section): Likewise.
	* elf64-x86-64.c (x86_64_elf_howto_table): Add 16-bit
	R_X86_64_PC16 entry.
	(elf_x86_64_rtype_to_howto): Use 16-bit R_X86_64_PC16 if input
	has 16-bit mode instructions.
	* elfxx-x86.c (_bfd_x86_elf_parse_gnu_properties): Set
	elf_x86_has_code16 if relocatable input is marked with
	GNU_PROPERTY_X86_FEATURE_2_CODE16.
	* elfxx-x86.h (elf_x86_obj_tdata): Add has_code16.
	(elf_x86_has_code16): New.

binutils/

	PR ld/27905
	* readelf.c (decode_x86_feature_2): Support
	GNU_PROPERTY_X86_FEATURE_2_CODE16.

gas/

	PR ld/27905
	* config/tc-i386.c (set_code_flag): Update x86_feature_2_used
	with GNU_PROPERTY_X86_FEATURE_2_CODE16 for .code16 in ELF
	object.
	(set_16bit_gcc_code_flag): Likewise.
	(x86_cleanup): Always generate the GNU property note if
	x86_feature_2_used isn't 0.
	* testsuite/gas/i386/code16-2.d: New file.
	* testsuite/gas/i386/code16-2.s: Likewise.
	* testsuite/gas/i386/x86-64-code16-2.d: Likewise.
	* testsuite/gas/i386/i386.exp: Run code16-2 and x86-64-code16-2.

include/

	PR ld/27905
	* elf/common.h (GNU_PROPERTY_X86_FEATURE_2_CODE16): New.

ld/

	PR ld/27905
	* testsuite/ld-i386/code16.d: New file.
	* testsuite/ld-i386/code16.t: Likewise.
	* testsuite/ld-x86-64/code16.d: Likewise.
	* testsuite/ld-x86-64/code16.t: Likewise.
	* testsuite/ld-i386/i386.exp: Run code16.
	* testsuite/ld-x86-64/x86-64.exp: Likewise.
2021-05-26 12:13:24 -07:00
Alan Modra
0a1b45a20e Use bool in bfd
* sysdep.h: POISON_BFD_BOOLEAN: Define.
	* aix5ppc-core.c, * aout-cris.c, * aout-ns32k.c, * aout-target.h,
	* aoutx.h, * arc-got.h, * archive.c, * archive64.c, * archures.c,
	* bfd-in.h, * bfd.c, * bfdwin.c, * binary.c, * cache.c,
	* coff-alpha.c, * coff-arm.c, * coff-arm.h, * coff-bfd.c,
	* coff-bfd.h, * coff-go32.c, * coff-i386.c, * coff-ia64.c,
	* coff-mcore.c, * coff-mips.c, * coff-rs6000.c, * coff-sh.c,
	* coff-stgo32.c, * coff-tic30.c, * coff-tic4x.c, * coff-tic54x.c,
	* coff-x86_64.c, * coff-z80.c, * coff-z8k.c, * coff64-rs6000.c,
	* coffcode.h, * coffgen.c, * cofflink.c, * compress.c,
	* corefile.c, * cpu-aarch64.c, * cpu-aarch64.h, * cpu-alpha.c,
	* cpu-arc.c, * cpu-arm.c, * cpu-arm.h, * cpu-avr.c, * cpu-bfin.c,
	* cpu-bpf.c, * cpu-cr16.c, * cpu-cris.c, * cpu-crx.c,
	* cpu-csky.c, * cpu-d10v.c, * cpu-d30v.c, * cpu-dlx.c,
	* cpu-epiphany.c, * cpu-fr30.c, * cpu-frv.c, * cpu-ft32.c,
	* cpu-h8300.c, * cpu-hppa.c, * cpu-i386.c, * cpu-ia64.c,
	* cpu-iamcu.c, * cpu-ip2k.c, * cpu-iq2000.c, * cpu-k1om.c,
	* cpu-l1om.c, * cpu-lm32.c, * cpu-m10200.c, * cpu-m10300.c,
	* cpu-m32c.c, * cpu-m32r.c, * cpu-m68hc11.c, * cpu-m68hc12.c,
	* cpu-m68k.c, * cpu-m9s12x.c, * cpu-m9s12xg.c, * cpu-mcore.c,
	* cpu-mep.c, * cpu-metag.c, * cpu-microblaze.c, * cpu-mips.c,
	* cpu-mmix.c, * cpu-moxie.c, * cpu-msp430.c, * cpu-mt.c,
	* cpu-nds32.c, * cpu-nfp.c, * cpu-nios2.c, * cpu-ns32k.c,
	* cpu-or1k.c, * cpu-pdp11.c, * cpu-pj.c, * cpu-powerpc.c,
	* cpu-pru.c, * cpu-riscv.c, * cpu-rl78.c, * cpu-rs6000.c,
	* cpu-rx.c, * cpu-s12z.c, * cpu-s390.c, * cpu-score.c,
	* cpu-sh.c, * cpu-sparc.c, * cpu-spu.c, * cpu-tic30.c,
	* cpu-tic4x.c, * cpu-tic54x.c, * cpu-tic6x.c, * cpu-tilegx.c,
	* cpu-tilepro.c, * cpu-v850.c, * cpu-v850_rh850.c, * cpu-vax.c,
	* cpu-visium.c, * cpu-wasm32.c, * cpu-xc16x.c, * cpu-xgate.c,
	* cpu-xstormy16.c, * cpu-xtensa.c, * cpu-z80.c, * cpu-z8k.c,
	* dwarf1.c, * dwarf2.c, * ecoff-bfd.h, * ecoff.c, * ecofflink.c,
	* elf-attrs.c, * elf-bfd.h, * elf-eh-frame.c, * elf-hppa.h,
	* elf-ifunc.c, * elf-m10200.c, * elf-m10300.c, * elf-nacl.c,
	* elf-nacl.h, * elf-properties.c, * elf-s390-common.c,
	* elf-s390.h, * elf-strtab.c, * elf-vxworks.c, * elf-vxworks.h,
	* elf.c, * elf32-am33lin.c, * elf32-arc.c, * elf32-arm.c,
	* elf32-arm.h, * elf32-avr.c, * elf32-avr.h, * elf32-bfin.c,
	* elf32-bfin.h, * elf32-cr16.c, * elf32-cr16.h, * elf32-cris.c,
	* elf32-crx.c, * elf32-csky.c, * elf32-csky.h, * elf32-d10v.c,
	* elf32-d30v.c, * elf32-dlx.c, * elf32-epiphany.c,
	* elf32-fr30.c, * elf32-frv.c, * elf32-ft32.c, * elf32-gen.c,
	* elf32-h8300.c, * elf32-hppa.c, * elf32-hppa.h, * elf32-i386.c,
	* elf32-ip2k.c, * elf32-iq2000.c, * elf32-lm32.c, * elf32-m32c.c,
	* elf32-m32r.c, * elf32-m68hc11.c, * elf32-m68hc12.c,
	* elf32-m68hc1x.c, * elf32-m68hc1x.h, * elf32-m68k.c,
	* elf32-m68k.h, * elf32-mcore.c, * elf32-mep.c, * elf32-metag.c,
	* elf32-metag.h, * elf32-microblaze.c, * elf32-mips.c,
	* elf32-moxie.c, * elf32-msp430.c, * elf32-mt.c, * elf32-nds32.c,
	* elf32-nios2.c, * elf32-nios2.h, * elf32-or1k.c, * elf32-pj.c,
	* elf32-ppc.c, * elf32-ppc.h, * elf32-pru.c, * elf32-rl78.c,
	* elf32-rx.c, * elf32-s12z.c, * elf32-s390.c, * elf32-score.c,
	* elf32-score.h, * elf32-score7.c, * elf32-sh-relocs.h,
	* elf32-sh.c, * elf32-sparc.c, * elf32-spu.c, * elf32-spu.h,
	* elf32-tic6x.c, * elf32-tic6x.h, * elf32-tilegx.c,
	* elf32-tilepro.c, * elf32-v850.c, * elf32-v850.h,
	* elf32-vax.c, * elf32-visium.c, * elf32-wasm32.c,
	* elf32-xc16x.c, * elf32-xgate.c, * elf32-xstormy16.c,
	* elf32-xtensa.c, * elf32-z80.c, * elf64-alpha.c, * elf64-bpf.c,
	* elf64-gen.c, * elf64-hppa.c, * elf64-ia64-vms.c,
	* elf64-mips.c, * elf64-mmix.c, * elf64-nfp.c, * elf64-ppc.c,
	* elf64-ppc.h, * elf64-s390.c, * elf64-sparc.c,
	* elf64-tilegx.c, * elf64-x86-64.c, * elfcode.h,
	* elfcore.h, * elflink.c, * elfn32-mips.c, * elfnn-aarch64.c,
	* elfnn-ia64.c, * elfnn-riscv.c, * elfxx-aarch64.c,
	* elfxx-aarch64.h, * elfxx-ia64.c, * elfxx-ia64.h,
	* elfxx-mips.c, * elfxx-mips.h, * elfxx-riscv.c, * elfxx-riscv.h,
	* elfxx-sparc.c, * elfxx-sparc.h, * elfxx-target.h,
	* elfxx-tilegx.c, * elfxx-tilegx.h, * elfxx-x86.c, * elfxx-x86.h,
	* format.c, * genlink.h, * hash.c, * i386aout.c, * i386lynx.c,
	* i386msdos.c, * ihex.c, * libaout.h, * libbfd-in.h,
	* libbfd.c, * libcoff-in.h, * libecoff.h, * libpei.h,
	* libxcoff.h, * linker.c, * mach-o-aarch64.c, * mach-o-arm.c,
	* mach-o-i386.c, * mach-o-x86-64.c, * mach-o.c, * mach-o.h,
	* merge.c, * mmo.c, * netbsd.h, * opncls.c, * pc532-mach.c,
	* pdp11.c, * pe-arm.c, * pe-i386.c, * pe-mcore.c, * pe-sh.c,
	* pe-x86_64.c, * peXXigen.c, * pef.c, * pei-arm.c, * pei-i386.c,
	* pei-ia64.c, * pei-mcore.c, * pei-sh.c, * pei-x86_64.c,
	* peicode.h, * plugin.c, * plugin.h, * ppcboot.c, * reloc.c,
	* reloc16.c, * rs6000-core.c, * section.c, * simple.c, * som.c,
	* som.h, * srec.c, * stabs.c, * syms.c, * targets.c, * tekhex.c,
	* verilog.c, * vms-alpha.c, * vms-lib.c, * vms-misc.c, * vms.h,
	* wasm-module.c, * xcofflink.c, * xcofflink.h, * xsym.c,
	* xsym.h: Replace bfd_boolean with bool, FALSE with false, and
	TRUE with true throughout.
	* bfd-in2.h: Regenerate.
	* libbfd.h: Regenerate.
	* libcoff.h: Regenerate.
2021-03-31 10:49:23 +10:30
Alan Modra
1201fda61b hash table iterator callback functions int vs. bfd_boolean
Correct return type of callbacks invoked by htab_traverse and other
hashtab.h functions to int, and one case of a callback invoked by
elf_link_hash_traverse to bfd_boolean.

	* elf32-i386.c (elf_i386_finish_local_dynamic_symbol): Return int.
	* elf64-ia64-vms.c (elf64_ia64_local_dyn_info_free): Likewise.
	(elf64_ia64_local_dyn_sym_thunk): Likewise.
	* elf64-x86-64.c (elf_x86_64_finish_local_dynamic_symbol): Likewise.
	* elfnn-aarch64.c (elfNN_aarch64_allocate_local_ifunc_dynrelocs),
	(elfNN_aarch64_finish_local_dynamic_symbol): Likewise.
	* elfnn-ia64.c (elfNN_ia64_local_dyn_info_free): Likewise.
	(elfNN_ia64_local_dyn_sym_thunk): Likewise.
	* elfnn-riscv.c (allocate_local_ifunc_dynrelocs): Likewise.
	(riscv_pcrel_reloc_eq): Likewise.
	(riscv_elf_finish_local_dynamic_symbol): Likewise.
	* elfxx-sparc.c (allocate_local_dynrelocs): Likewise.
	(finish_local_dynamic_symbol): Likewise.
	* elfxx-x86.c (elf_x86_allocate_local_dynreloc): Likewise.
	* elfxx-mips.c (mips_elf_resolve_got_page_ref): Likewise.
	(mips_elf_count_got_symbols): Change return type to bfd_boolean.
2021-03-29 11:22:21 +10:30
Martin Liska
08dedd6631 Add startswith function and use it instead of CONST_STRNEQ.
bfd/ChangeLog:

	* bfd-in.h (startswith): Add startswith function.
	(CONST_STRNEQ): Remove.
	* bfd-in2.h (startswith): Regenerate with make headers.
	* archive.c (bfd_slurp_armap): Replace usage of CONST_STRNEQ with startswith.
	(_bfd_slurp_extended_name_table): Likewise.
	* archive64.c (_bfd_archive_64_bit_slurp_armap): Likewise.
	* bfd.c (bfd_get_sign_extend_vma): Likewise.
	(bfd_convert_section_size): Likewise.
	(bfd_convert_section_contents): Likewise.
	* coff-stgo32.c (go32exe_create_stub): Likewise.
	(go32exe_check_format): Likewise.
	* coffcode.h (styp_to_sec_flags): Likewise.
	(GNU_DEBUGALTLINK): Likewise.
	* coffgen.c (_bfd_coff_section_already_linked): Likewise.
	(coff_gc_sweep): Likewise.
	(bfd_coff_gc_sections): Likewise.
	* cofflink.c (coff_link_add_symbols): Likewise.
	(process_embedded_commands): Likewise.
	* compress.c (bfd_is_section_compressed_with_header): Likewise.
	(bfd_init_section_decompress_status): Likewise.
	* dwarf2.c (find_debug_info): Likewise.
	(place_sections): Likewise.
	* ecoff.c (_bfd_ecoff_slurp_armap): Likewise.
	* elf-m10300.c (_bfd_mn10300_elf_size_dynamic_sections): Likewise.
	* elf.c (_bfd_elf_make_section_from_shdr): Likewise.
	(assign_section_numbers): Likewise.
	(elfcore_grok_win32pstatus): Likewise.
	* elf32-arm.c (cmse_scan): Likewise.
	(elf32_arm_gc_mark_extra_sections): Likewise.
	(elf32_arm_size_dynamic_sections): Likewise.
	(is_arm_elf_unwind_section_name): Likewise.
	* elf32-bfin.c (bfin_size_dynamic_sections): Likewise.
	* elf32-cr16.c (_bfd_cr16_elf_size_dynamic_sections): Likewise.
	* elf32-cris.c (elf_cris_size_dynamic_sections): Likewise.
	* elf32-csky.c (csky_elf_size_dynamic_sections): Likewise.
	* elf32-hppa.c (elf32_hppa_size_dynamic_sections): Likewise.
	* elf32-iq2000.c (iq2000_elf_check_relocs): Likewise.
	* elf32-lm32.c (lm32_elf_size_dynamic_sections): Likewise.
	* elf32-m32r.c (m32r_elf_size_dynamic_sections): Likewise.
	* elf32-m68k.c (elf_m68k_size_dynamic_sections): Likewise.
	* elf32-metag.c (elf_metag_size_dynamic_sections): Likewise.
	* elf32-msp430.c (msp430_elf_relax_delete_bytes): Likewise.
	* elf32-nios2.c (nios2_elf32_size_dynamic_sections): Likewise.
	* elf32-or1k.c (or1k_elf_size_dynamic_sections): Likewise.
	* elf32-ppc.c (ppc_elf_size_dynamic_sections): Likewise.
	* elf32-s390.c (elf_s390_size_dynamic_sections): Likewise.
	* elf32-score.c (s3_bfd_score_elf_size_dynamic_sections): Likewise.
	* elf32-score7.c (s7_bfd_score_elf_size_dynamic_sections): Likewise.
	* elf32-sh.c (sh_elf_size_dynamic_sections): Likewise.
	* elf32-tic6x.c (is_tic6x_elf_unwind_section_name): Likewise.
	(elf32_tic6x_size_dynamic_sections): Likewise.
	* elf32-vax.c (elf_vax_size_dynamic_sections): Likewise.
	* elf32-xtensa.c (elf_xtensa_size_dynamic_sections): Likewise.
	(xtensa_is_insntable_section): Likewise.
	(xtensa_is_littable_section): Likewise.
	(xtensa_is_proptable_section): Likewise.
	(xtensa_property_section_name): Likewise.
	(xtensa_callback_required_dependence): Likewise.
	* elf64-alpha.c (elf64_alpha_size_dynamic_sections): Likewise.
	* elf64-hppa.c (elf64_hppa_size_dynamic_sections): Likewise.
	* elf64-ia64-vms.c (is_unwind_section_name): Likewise.
	(get_reloc_section): Likewise.
	(elf64_ia64_size_dynamic_sections): Likewise.
	(elf64_ia64_object_p): Likewise.
	* elf64-mmix.c (mmix_elf_add_symbol_hook): Likewise.
	* elf64-ppc.c (ppc64_elf_size_dynamic_sections): Likewise.
	* elf64-s390.c (elf_s390_size_dynamic_sections): Likewise.
	* elflink.c (elf_link_add_object_symbols): Likewise.
	(_bfd_elf_gc_mark_extra_sections): Likewise.
	(bfd_elf_parse_eh_frame_entries): Likewise.
	(_bfd_elf_section_already_linked): Likewise.
	* elfnn-aarch64.c (elfNN_aarch64_size_dynamic_sections): Likewise.
	* elfnn-ia64.c (is_unwind_section_name): Likewise.
	(elfNN_ia64_size_dynamic_sections): Likewise.
	(elfNN_ia64_object_p): Likewise.
	* elfxx-mips.c (FN_STUB_P): Likewise.
	(CALL_STUB_P): Likewise.
	(CALL_FP_STUB_P): Likewise.
	(_bfd_mips_elf_section_from_shdr): Likewise.
	(_bfd_mips_elf_fake_sections): Likewise.
	(_bfd_mips_elf_size_dynamic_sections): Likewise.
	(_bfd_mips_final_write_processing): Likewise.
	(_bfd_mips_elf_final_link): Likewise.
	* elfxx-sparc.c (_bfd_sparc_elf_size_dynamic_sections): Likewise.
	* elfxx-x86.c (elf_i386_is_reloc_section): Likewise.
	(elf_x86_64_is_reloc_section): Likewise.
	* hpux-core.c (thread_section_p): Likewise.
	* libcoff.h (bfd_pei_p): Likewise.
	* linker.c (REAL): Likewise.
	(unwrap_hash_lookup): Likewise.
	(_bfd_generic_link_add_one_symbol): Likewise.
	* mmo.c (mmo_internal_write_section): Likewise.
	* osf-core.c (osf_core_core_file_p): Likewise.
	* pef.c (bfd_pef_print_symbol): Likewise.
	* pei-x86_64.c (pex64_print_all_pdata_sections): Likewise.
	* som.c (som_slurp_symbol_table): Likewise.
	(som_slurp_armap): Likewise.
	* wasm-module.c (wasm_compute_custom_section_file_position): Likewise.

binutils/ChangeLog:

	* dlltool.c (scan_drectve_symbols): Replace usage of CONST_STRNEQ with startswith.
	* emul_aix.c (ar_emul_aix_parse_arg): Likewise.
	* objcopy.c (is_mergeable_note_section): Likewise.
	* objdump.c (dump_dwarf_section): Likewise.
	* prdbg.c (pr_method_type): Likewise.
	(pr_class_baseclass): Likewise.
	(tg_class_baseclass): Likewise.
	* readelf.c (process_lto_symbol_tables): Likewise.
	* stabs.c (ULLHIGH): Likewise.
	(parse_stab_argtypes): Likewise.
	(stab_demangle_function_name): Likewise.

gas/ChangeLog:

	* config/tc-i386.c (md_parse_option): Replace usage of CONST_STRNEQ with startswith.
	(x86_64_section_word): Likewise.
	* config/tc-sparc.c (md_parse_option): Likewise.

gdb/ChangeLog:

	* arm-tdep.c (show_disassembly_style_sfunc): Replace usage of CONST_STRNEQ with startswith.
	(_initialize_arm_tdep): Likewise.

ld/ChangeLog:

	* emultempl/aix.em: Replace usage of CONST_STRNEQ with startswith.
	* emultempl/beos.em: Likewise.
	* emultempl/elf.em: Likewise.
	* emultempl/pe.em: Likewise.
	* emultempl/pep.em: Likewise.
	* emultempl/xtensaelf.em: Likewise.
	* ldctor.c (ctor_prio): Likewise.
	* ldelf.c (ldelf_try_needed): Likewise.
	(ldelf_parse_ld_so_conf): Likewise.
	(ldelf_after_open): Likewise.
	(output_rel_find): Likewise.
	(ldelf_place_orphan): Likewise.
	* ldfile.c (ldfile_add_library_path): Likewise.
	* ldlang.c (lang_add_input_file): Likewise.
	* ldmain.c (get_sysroot): Likewise.
	(get_emulation): Likewise.
	(add_archive_element): Likewise.
	* ldwrite.c (unsplittable_name): Likewise.
	(clone_section): Likewise.
	* lexsup.c (parse_args): Likewise.
	* pe-dll.c (is_import): Likewise.
	(pe_implied_import_dll): Likewise.

opcodes/ChangeLog:

	* aarch64-dis.c (parse_aarch64_dis_option): Replace usage of CONST_STRNEQ with startswith.
	* arc-dis.c (parse_option): Likewise.
	* arm-dis.c (parse_arm_disassembler_options): Likewise.
	* cris-dis.c (print_with_operands): Likewise.
	* h8300-dis.c (bfd_h8_disassemble): Likewise.
	* i386-dis.c (print_insn): Likewise.
	* ia64-gen.c (fetch_insn_class): Likewise.
	(parse_resource_users): Likewise.
	(in_iclass): Likewise.
	(lookup_specifier): Likewise.
	(insert_opcode_dependencies): Likewise.
	* mips-dis.c (parse_mips_ase_option): Likewise.
	(parse_mips_dis_option): Likewise.
	* s390-dis.c (disassemble_init_s390): Likewise.
	* wasm32-dis.c (parse_wasm32_disassembler_options): Likewise.
2021-03-22 11:01:43 +01:00
H.J. Lu
75a933f399 ld/elf/x86: Don't compare IFUNC address in the shared object
On x86, glibc 2.33 starts to issue a fatal error message when calling
IFUNC function defined in the unrelocated executable from a shared
library.

1. Update x86 ELF linker to always convert IFUNC function defined in
position-dependent executable (PDE) to the normal function.  GOT in PDE
will be updated by R_*_IRELATIVE at run-time.
2. Update PR ld/23169 tests not to compare function address of external
IFUNC function in the shared object to avoid calling the IFUNC function
defined in the unrelocated executable.
3. Remove pr23169e tests which call the IFUNC function defined in the
unrelocated position-independent executable from a shared library.

bfd/

	PR ld/23169
	* elfxx-x86.c (_bfd_x86_elf_link_fixup_ifunc_symbol): Don't
	check pointer_equality_needed.

ld/

	PR ld/23169
	* testsuite/ld-ifunc/ifunc.exp: Replace pr23169c.rd with
	pr23169a.rd for pr23169c and pr23169f.  Remove pr23169e tests.
	* testsuite/ld-ifunc/pr23169a.c (foo): Don't compare function
	address.
2021-01-16 07:02:36 -08:00
H.J. Lu
68b007788a ld/x86: Add -z report-relative-reloc
Linker generated relative relocations don't have symbol info:

[hjl@gnu-cfl-2 tmpdir]$ readelf -rW dump

Relocation section '.rela.dyn' at offset 0x180 contains 2 entries:
 Offset     Info    Type                Sym. Value  Symbol's Name + Addend
00002f70  00000008 R_X86_64_RELATIVE                 1000
00002f68  00000025 R_X86_64_IRELATIVE                1007
[hjl@gnu-cfl-2 tmpdir]$

Add -z report-relative-reloc to x86 ELF linker to report dynamic relative
relocations:

[hjl@gnu-cfl-2 tmpdir]$ ../ld-new -pie -melf32_x86_64 -z report-relative-reloc -o dump report-reloc-1.o
dump: R_X86_64_IRELATIVE (offset: 0x00002f68, info: 0x00000025, addend: 0x00001007) against 'ifunc' for section '.data.rel.ro.local' in report-reloc-1.o
dump: R_X86_64_RELATIVE (offset: 0x00002f70, info: 0x00000008, addend: 0x00001000) against '_start' for section '.data.rel.ro.local' in report-reloc-1.o
[hjl@gnu-cfl-2 tmpdir]$

It can be used to map relative relocations to corresponding symbols.

bfd/

	* elf-linker-x86.h (elf_linker_x86_params): Add
	report_relative_reloc.
	* elf32-i386.c (elf_i386_relocate_section): Call
	_bfd_x86_elf_link_report_relative_reloc to report relative
	relocations for -z report-relative-reloc.
	(elf_i386_finish_dynamic_symbol): Likewse.
	* elf64-x86-64.c (elf_x86_64_relocate_section): Likewse.
	(elf_x86_64_finish_dynamic_symbol): Likewse.
	* elfxx-x86.c (_bfd_x86_elf_link_report_relative_reloc): New
	function.
	* elfxx-x86.h (_bfd_x86_elf_link_report_relative_reloc): New
	prototype.

ld/

	* NEWS: Mention -z report-relative-reloc.
	* ld.texi: Document -z report-relative-reloc.
	* emulparams/elf32_x86_64.sh: Source x86-report-relative.sh.
	* emulparams/elf_i386.sh: Likewse.
	* emulparams/elf_x86_64.sh: Likewse.
	* emulparams/x86-report-relative.sh: New file.
	* testsuite/ld-i386/report-reloc-1.d: Likewse.
	* testsuite/ld-i386/report-reloc-1.l: Likewse.
	* testsuite/ld-i386/report-reloc-1.s: Likewse.
	* testsuite/ld-x86-64/report-reloc-1-x32.d: Likewse.
	* testsuite/ld-x86-64/report-reloc-1.d: Likewse.
	* testsuite/ld-x86-64/report-reloc-1.l: Likewse.
	* testsuite/ld-x86-64/report-reloc-1.s: Likewse.
	* testsuite/ld-i386/i386.exp: Run report-reloc-1.
	* testsuite/ld-x86-64/x86-64.exp: Run report-reloc-1 and
	report-reloc-1-x32.
2021-01-15 18:07:07 -08:00
H.J. Lu
0a94990bf6 ld/x86-64: Properly Handle -z lam-u48/lam-u57
Properly merge GNU properties for LAM_U48 and LAM_U57.

bfd/

	PR ld/27166
	* elfxx-x86.c (_bfd_x86_elf_merge_gnu_properties): Handle
	-z lam-u48 and -z lam-u57.

ld/

	PR ld/27166
	* testsuite/ld-x86-64/lam-u48.rd: New file.
	* testsuite/ld-x86-64/lam-u57.rd: Likewise.
	* testsuite/ld-x86-64/x86-64.exp: Add PR ld/27166 tests.
2021-01-09 06:13:11 -08:00
H.J. Lu
ba9e922fa0 ld/x86-64: Also set LAM_U57 when setting LAM_U48
Since LAM_U48 implies LAM_U57, also set LAM_U57 when setting LAM_U48.

bfd/

	* elfxx-x86.c (_bfd_x86_elf_link_setup_gnu_properties): Also set
	LAM_U57 when setting LAM_U48.

ld/

	* ld-x86-64/property-x86-lam-u48-4.d: Updated.
	* ld-x86-64/property-x86-lam-u48-5.d: Likewise.
2021-01-08 21:51:48 -08:00
Alan Modra
250d07de5c Update year range in copyright notice of binutils files 2021-01-01 10:31:05 +10:30
H.J. Lu
279d901e5a x86-64: Add Intel LAM property support
Add Intel Linear Address Masking (LAM) property support.  LAM modifies
the checking that is applied to 64-bit linear addresses, allowing
software to use of the untranslated address bits for metadata.

bfd/

	* elf-linker-x86.h (elf_x86_cet_report): Renamed to ...
	(elf_x86_prop_report): This.
	(elf_linker_x86_params): Add lam_u48, lam_u57, lam_u48_report
	and lam_u57_report.
	* elfxx-x86.c (_bfd_x86_elf_link_setup_gnu_properties): Support
	GNU_PROPERTY_X86_FEATURE_1_LAM_U48 and
	GNU_PROPERTY_X86_FEATURE_1_LAM_U57.
	(_bfd_x86_elf_link_fixup_gnu_properties): Keep LAM features only
	for 64-bit output.

binutils/

	* NEWS: Mention LAM_U48 and LAM_U57 support.
	* elfedit.c (elf_x86_feature): Support lam_u48 and lam_u57.
	(usage): Add lam_u48 and lam_u57.
	* readelf.c (decode_x86_feature_1): Support LAM_U48 and LAM_U57.
	* doc/binutils.texi: Update elfedit with lam_u48 and lam_u57
	support.
	* testsuite/binutils-all/x86-64/lam-u48.d: New file.
	* testsuite/binutils-all/x86-64/lam-u48.s: Likewise.
	* testsuite/binutils-all/x86-64/lam-u57.d: Likewise.
	* testsuite/binutils-all/x86-64/lam-u57.s: Likewise.

include/

	* elf/common.h (GNU_PROPERTY_X86_FEATURE_1_LAM_U48): New.
	(GNU_PROPERTY_X86_FEATURE_1_LAM_U57): Likewise.

ld/

	* NEWS: Mention LAM_U48 and LAM_U57 support.
	* ld.texi: Document LAM_U48 and LAM_U57 support.
	* emulparams/cet.sh: Updated.
	* emulparams/elf_x86_64.sh: Source x86-64-lam.sh.
	* emulparams/x86-64-lam.sh: New file.
	* testsuite/ld-x86-64/property-x86-lam-u48-1a.d: Likewise.
	* testsuite/ld-x86-64/property-x86-lam-u48-1b.d: Likewise.
	* testsuite/ld-x86-64/property-x86-lam-u48-2.d: Likewise.
	* testsuite/ld-x86-64/property-x86-lam-u48-3a.d: Likewise.
	* testsuite/ld-x86-64/property-x86-lam-u48-3b.d: Likewise.
	* testsuite/ld-x86-64/property-x86-lam-u48-4.d: Likewise.
	* testsuite/ld-x86-64/property-x86-lam-u48-5.d: Likewise.
	* testsuite/ld-x86-64/property-x86-lam-u48.s: Likewise.
	* testsuite/ld-x86-64/property-x86-lam-u57-1a.d: Likewise.
	* testsuite/ld-x86-64/property-x86-lam-u57-1b.d: Likewise.
	* testsuite/ld-x86-64/property-x86-lam-u57-2.d: Likewise.
	* testsuite/ld-x86-64/property-x86-lam-u57-3a.d: Likewise.
	* testsuite/ld-x86-64/property-x86-lam-u57-3b.d: Likewise.
	* testsuite/ld-x86-64/property-x86-lam-u57-4.d: Likewise.
	* testsuite/ld-x86-64/property-x86-lam-u57-5.d: Likewise.
	* testsuite/ld-x86-64/property-x86-lam-u57.s: Likewise.
	* testsuite/ld-x86-64/x86-64.exp: Run LAM tests.
2020-12-23 13:00:55 -08:00