]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commit
x86: Check invalid GOT/PLT/TLS relocations master
authorH.J. Lu <hjl.tools@gmail.com>
Thu, 30 Jul 2026 05:43:56 +0000 (13:43 +0800)
committerH.J. Lu <hjl.tools@gmail.com>
Tue, 4 Aug 2026 03:09:38 +0000 (11:09 +0800)
commit471130b39c03623ec6d78ece377ff4da3f6bfe7b
tree31e199f6831b084bae6fe4d49a566788f1a6ef6f
parent7322e9bc30cb282575a701c307851fd3d66fee68
x86: Check invalid GOT/PLT/TLS relocations

1. Since non-alloc sections aren't checked for TLS, GOT and PLT usages,
relocate_section should issue error for TLS, GOT and PLT relocations in
non-alloc and non-debugging sections.
2. Since TLS relocations must be against thread local symbols, scan_relocs
should issue an error for TLS relocation against non-thread local symbol.

PR ld/34444
PR ld/34448
* elf32-i386.c (elf_i386_tls_transition): Replace
_bfd_x86_elf_link_report_tls_invalid_section_error with
_bfd_x86_elf_link_report_error.
(elf_i386_scan_relocs): Issue an error for TLS relocation against
non-thread local symbol.
(elf_i386_relocate_section): Issue error for TLS, GOT and PLT
relocations in non-alloc and non-debugging sections.
* elf64-x86-64.c (elf_x86_64_tls_transition): Replace
_bfd_x86_elf_link_report_tls_invalid_section_error with
_bfd_x86_elf_link_report_error.
(elf_x86_64_scan_relocs): Issue an error for TLS relocation
against non-thread local symbol.
* elfxx-x86.c (_bfd_x86_elf_link_report_tls_invalid_section_error):
Renamed to ...
(_bfd_x86_elf_link_report_error): This.  Add an argument for
link error type and handle it.
* elfxx-x86.h (elf_x86_error_type): New enum.
(_bfd_x86_elf_link_report_tls_invalid_section_error): Renamed
to ...
(_bfd_x86_elf_link_report_error): This.  Add an argument of
enum elf_x86_error_type.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
bfd/elf32-i386.c
bfd/elf64-x86-64.c
bfd/elfxx-x86.c
bfd/elfxx-x86.h