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
..
2019-09-11 13:45:18 +09:30
2019-09-11 13:45:18 +09:30
2022-12-14 21:45:04 +10:30
2019-09-11 13:45:18 +09:30
2019-09-11 13:45:18 +09:30
2017-10-12 23:30:43 +10:30
2018-10-13 20:33:23 +10:30
2019-09-11 13:45:18 +09:30
2019-09-11 13:45:18 +09:30
2019-09-11 13:45:18 +09:30
2022-12-14 21:45:04 +10:30
2019-09-11 13:45:18 +09:30
2019-09-11 13:45:18 +09:30
2019-09-11 13:45:18 +09:30
2019-09-11 13:45:18 +09:30
2019-09-11 13:45:18 +09:30
2019-09-11 13:45:18 +09:30
2019-09-11 13:45:18 +09:30
2019-09-11 13:45:18 +09:30
2019-09-11 13:45:18 +09:30
2019-09-11 13:45:18 +09:30
2019-09-11 13:45:18 +09:30
2019-09-11 13:45:18 +09:30
2019-09-11 13:45:18 +09:30
2019-09-11 13:45:18 +09:30
2019-09-11 13:45:18 +09:30
2019-09-11 13:45:18 +09:30
2019-09-11 13:45:18 +09:30
2019-09-11 13:45:18 +09:30
2019-09-11 13:45:18 +09:30
2019-09-11 13:45:18 +09:30
2019-09-11 13:45:18 +09:30
2021-03-31 10:49:23 +10:30
2021-03-31 10:49:23 +10:30
2019-09-11 13:45:18 +09:30
2019-09-11 13:45:18 +09:30
2019-09-11 13:45:18 +09:30
2022-01-12 06:04:29 -08:00
2021-03-31 10:49:23 +10:30
2019-09-11 13:45:18 +09:30
2019-09-11 13:45:18 +09:30
2019-09-11 13:45:18 +09:30
2021-03-31 10:49:23 +10:30
2019-09-11 13:45:18 +09:30
2019-09-11 13:45:18 +09:30
2019-09-11 13:45:18 +09:30
2019-09-11 13:45:18 +09:30
2019-09-11 13:45:18 +09:30
2019-09-11 13:45:18 +09:30
2019-09-11 13:45:18 +09:30
2023-08-16 14:22:54 +01:00
2021-03-31 10:49:23 +10:30
2021-10-24 21:36:32 +10:30
2021-10-24 21:36:32 +10:30
2021-03-31 10:49:23 +10:30
2021-03-31 10:49:23 +10:30
2019-09-11 13:45:18 +09:30
2019-09-11 13:45:18 +09:30
2019-09-11 13:45:18 +09:30
2019-09-11 13:45:18 +09:30
2019-09-11 13:45:18 +09:30
2019-09-11 13:45:18 +09:30
2019-09-11 13:45:18 +09:30
2019-09-11 13:45:18 +09:30
2019-09-11 13:45:18 +09:30
2022-12-14 21:45:04 +10:30
2019-09-11 13:45:18 +09:30
2019-09-11 13:45:18 +09:30
2019-09-11 13:45:18 +09:30
2019-09-11 13:45:18 +09:30
2019-09-11 13:45:18 +09:30
2021-03-31 10:49:23 +10:30
2019-09-11 13:45:18 +09:30
2019-09-11 13:45:18 +09:30
2019-09-11 13:45:18 +09:30
2019-09-11 13:45:18 +09:30
2023-08-02 12:06:23 +01:00
2019-09-11 13:45:18 +09:30
2019-09-11 13:45:18 +09:30
2019-09-11 13:45:18 +09:30
2019-09-11 13:45:18 +09:30
2023-08-16 14:22:54 +01:00
2023-08-16 14:22:54 +01:00
2021-10-24 21:36:32 +10:30
2021-10-24 21:36:32 +10:30
2022-07-25 09:49:41 +09:30
2019-09-11 13:45:18 +09:30
2019-09-11 13:45:18 +09:30
2019-09-11 13:45:18 +09:30
2019-09-11 13:45:18 +09:30
2022-01-12 06:04:29 -08:00
2022-12-14 21:45:04 +10:30
2023-08-02 12:06:23 +01:00
2022-12-14 21:45:04 +10:30
2019-09-11 13:45:18 +09:30
2019-09-11 13:45:18 +09:30
2019-09-11 13:45:18 +09:30
2019-09-11 13:45:18 +09:30
2019-09-11 13:45:18 +09:30
2019-09-11 13:45:18 +09:30
2019-09-11 13:45:18 +09:30
2019-05-30 01:01:42 +09:30
2019-09-11 13:45:18 +09:30
2019-09-11 13:45:18 +09:30
2019-09-11 13:45:18 +09:30
2019-09-11 13:45:18 +09:30
2019-09-11 13:45:18 +09:30
2019-09-11 13:45:18 +09:30
2019-09-11 13:45:18 +09:30
2019-09-11 13:45:18 +09:30
2019-09-11 13:45:18 +09:30
2019-09-11 13:45:18 +09:30
2019-09-11 13:45:18 +09:30
2019-09-11 13:45:18 +09:30
2019-09-11 13:45:18 +09:30
2021-03-31 10:49:23 +10:30
2019-09-11 13:45:18 +09:30
2021-03-31 10:49:23 +10:30
2019-09-11 13:45:18 +09:30
2019-09-11 13:45:18 +09:30
2019-09-11 13:45:18 +09:30
2019-09-11 13:45:18 +09:30
2021-03-31 10:49:23 +10:30
2019-09-11 13:45:18 +09:30
2019-09-11 13:45:18 +09:30
2017-10-12 23:30:43 +10:30
2021-03-31 10:49:23 +10:30
2020-11-03 08:56:27 +00:00
2018-07-10 23:59:07 +09:30

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

The files in this directory are read by genscripts.sh as shell commands.
They set parameters for the emulations.

Copyright (C) 2012-2023 Free Software Foundation, Inc.

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.