Commit graph

17533 commits

Author SHA1 Message Date
H.J. Lu
68c4956b14 x86: Properly handle function pointer reference
Update

commit ebb191adac
Author: H.J. Lu <hjl.tools@gmail.com>
Date:   Wed Feb 9 15:51:22 2022 -0800

    x86: Disallow invalid relocation against protected symbol

to allow function pointer reference and make sure that PLT entry isn't
used for function reference due to function pointer reference.

bfd/

	PR ld/29087
	* elf32-i386.c (elf_i386_scan_relocs): Don't set
	pointer_equality_needed nor check non-canonical reference for
	function pointer reference.
	* elf64-x86-64.c (elf_x86_64_scan_relocs): Likewise.

ld/

	PR ld/29087
	* testsuite/ld-x86-64/x86-64.exp: Run PR ld/29087 tests.
	* testsuite/ld-x86-64/protected-func-3.c: New file.
2022-04-28 09:20:30 -07:00
Stefan Liebler
d942d8db12 s390: Add DT_JMPREL pointing to .rela.[i]plt with static-pie
In static-pie case, there are IRELATIVE-relocs in
.rela.iplt (htab->irelplt), which will later be grouped
to .rela.plt.  On s390, the IRELATIVE relocations are
always located in .rela.iplt - even for non-static case.
Ensure that DT_JMPREL, DT_PLTRELA, DT_PLTRELASZ is added
to the dynamic section even if htab->srelplt->size == 0.
See _bfd_elf_add_dynamic_tags in bfd/elflink.c.

bfd/
	elf64-s390.c (elf_s390_size_dynamic_sections):
	Enforce DT_JMPREL via htab->elf.dt_jmprel_required.
2022-04-28 14:52:06 +02:00
Stefan Liebler
26b1426577 s390: Avoid dynamic TLS relocs in PIE
No dynamic relocs are needed for TLS defined in an executable, the
TP relative offset is known at link time.

Fixes
FAIL: Build pr22263-1

bfd/
	PR ld/22263
	* elf64-s390.c (elf_s390_tls_transition): Use bfd_link_dll
	instead of bfd_link_pic for TLS.
	(elf_s390_check_relocs): Likewise.
	(allocate_dynrelocs): Likewise.
	(elf_s390_relocate_section): Likewise.
2022-04-28 14:52:02 +02:00
GDB Administrator
dfb138f934 Automatic date update in version.in 2022-04-28 00:00:21 +00:00
John Baldwin
8e6afe4013 Create pseudo sections for NT_ARM_TLS notes on FreeBSD.
bfd/ChangeLog:

	* elf.c (elfcore_grok_freebsd_note): Handle NT_ARM_TLS notes.
2022-04-27 08:06:39 -07:00
GDB Administrator
2538fcd3f4 Automatic date update in version.in 2022-04-27 00:00:16 +00:00
GDB Administrator
df2a5f8de7 Automatic date update in version.in 2022-04-26 00:00:13 +00:00
Nick Clifton
0d38576a34 Emit a note warning the user that creating an executable stack because of a missing .note.GNU-stack section is deprecated.
PR 29072
bfd	* elflink.c (bfd_elf_size_dynamic_sections): Display a note to the
	user that the current ehaviour of creating an executable stack
	because of a missing .note.GNU-stack section is deprecated and
	will be changed in a future release.

binutils* testsuite/lib/binutils-common.exp (prune_warnings_extra): Filter
	out notes about the executable stacjk behaviour beign deprecated.

ld	* testsuite/ld-elf/pr29072.b.warn: Update to include the note
	about the linker's behaviour being depreccated.
2022-04-25 12:53:08 +01:00
GDB Administrator
455fe76708 Automatic date update in version.in 2022-04-25 00:00:15 +00:00
GDB Administrator
69be4d89e3 Automatic date update in version.in 2022-04-24 00:00:10 +00:00
GDB Administrator
7642f36b93 Automatic date update in version.in 2022-04-23 00:00:17 +00:00
GDB Administrator
61eabc63f9 Automatic date update in version.in 2022-04-22 00:00:20 +00:00
GDB Administrator
cae84d1c77 Automatic date update in version.in 2022-04-21 00:00:13 +00:00
Alan Modra
85649ec8eb Re: xcoff: implement linker relaxation
* xcofflink.c (xcoff_stub_csect_name): Increase buffer size.
	(xcoff_stub_get_csect_in_range, xcoff_build_one_stub): Whitespace.
	(bfd_xcoff_size_stubs): Cast PRIx64 arg to required type.
	Don't use freed stub_name.
2022-04-20 23:56:59 +09:30
Cl?ment Chigot
2d23f9656c xcoff: implement linker relaxation
bfd/ChangeLog:

	* coff-rs6000.c (xcoff_reloc_type_noop): Add info argument.
	(xcoff_reloc_type_fail): Likewise.
	(xcoff_reloc_type_pos): Likewise.
	(xcoff_reloc_type_neg): Likewise.
	(xcoff_reloc_type_rel): Likewise.
	(xcoff_reloc_type_toc): Likewise.
	(xcoff_reloc_type_ba): Likewise.
	(xcoff_reloc_type_crel): Likewise.
	(xcoff_reloc_type_tls): Likewise.
	(xcoff_reloc_type_br): Add stub handler.
	(xcoff_ppc_relocate_section): Add info to
	xcoff_calculate_relocation.
	(xcoff_stub_indirect_call_code): New constant.
	(xcoff_stub_shared_call_code): Likewise.
	(bfd_xcoff_backend_data): Add stub code fields.
	(bfd_pmac_xcoff_backend_data): Likewise.
	* coff64-rs6000.c (xcoff64_reloc_type_br): Add stub handler.
	(xcoff64_ppc_relocate_section): Add info to
	xcoff64_calculate_relocation.
	(xcoff64_stub_indirect_call_code): New constant.
	(xcoff64_stub_shared_call_code): Likewise.
	(bfd_xcoff_backend_data): Add stub code fields.
	(bfd_xcoff_aix5_backend_data): Likewise.
	* libxcoff.h (struct xcoff_backend_data_rec): Add stub fields.
	(bfd_xcoff_stub_indirect_call_code): New define.
	(bfd_xcoff_stub_indirect_call_size): New define.
	(bfd_xcoff_stub_shared_call_code): New define.
	(bfd_xcoff_stub_shared_call_size): New define.
	(xcoff_reloc_function): Add info argument.
	(enum xcoff_stub_type): New enum.
	(struct xcoff_stub_hash_entry): New structure.
	* xcofflink.c (struct xcoff_link_hash_table): Add stub hash
	table and params fields.
	(xcoff_stub_hash_entry): New define.
	(xcoff_stub_hash_lookup): New define.
	(stub_hash_newfunc): New function.
	(_bfd_xcoff_bfd_link_hash_table_free): Free the new stub hash
	table.
	(_bfd_xcoff_bfd_link_hash_table_create): Create the new stub
	hash table.
	(xcoff_link_add_symbols): Save rawsize for XTY_SD.
	(bfd_xcoff_link_init): New function.
	(xcoff_stub_csect_name): New function.
	(xcoff_stub_get_csect_in_range): New function.
	(xcoff_stub_name): New function.
	(bfd_xcoff_get_stub_entry): New function.
	(bfd_xcoff_type_of_stub): New function.
	(xcoff_add_stub): New function.
	(xcoff_build_one_stub): New function.
	(bfd_xcoff_size_stubs): New function.
	(bfd_xcoff_build_stubs): New function.
	(xcoff_stub_create_relocations): New function.
	(xcoff_link_input_bfd): Adapt relocations to stub.
	(xcoff_write_global_symbol): Adapt to new TOC entries generated
	for stubs.
	(_bfd_xcoff_bfd_final_link): Handle stub file.
	* xcofflink.h (struct bfd_xcoff_link_params): New structure.

ld/ChangeLog:

	* emultempl/aix.em (params): New variable.
	(stub_file): New variable.
	(xcoff_add_stub_section): New function.
	(xcoff_layout_sections_again): New function
	(hook_in_stub): New function.
	(_after_allocation): Add stub creation.
	(_create_output_section_statements): Allocate stub file and
	pass params to backend.
2022-04-20 15:11:47 +01:00
Cl?ment Chigot
1876a54217 Stubs (added in a later patch) will generate new .loader symbols, once the allocations have been done. Thus, the .loader section cannot be layout before that.
bfd/ChangeLog:

	* coff-rs6000.c (_bfd_xcoff_put_ldsymbol_name): Write len in
	  ldinfo->strings instead of directly in the output_bfd.
	* coff64-rs6000.c (_bfd_xcoff64_put_ldsymbol_name): Likewise.
	* xcofflink.c (struct xcoff_link_hash_table): Remove ldrel_count
	  field. Add ldinfo field.
	(xcoff_mark_symbol): Adjust to new ldinfo field.
	(xcoff_mark): Likewise.
	(bfd_xcoff_link_count_reloc): Likewise.
	(xcoff_build_loader_section): Split into two functions: one that
	build the loader section (this function) and one that only size
	it...
	(xcoff_size_loader_section): ... (this function).
	(bfd_xcoff_size_dynamic_sections): Adapt to new ldinfo field.
	Move the part where the dynamic sections are build to ...
	(bfd_xcoff_build_dynamic_sections): ... this function.
	* xcofflink.h: Add bfd_xcoff_build_dynamic_sections prototype.

include/ChangeLog:

	* coff/xcoff.h (struct xcoff_loader_info): Add ldrel_count and
	libpath fields.

ld/ChangeLog:

	* emultempl/aix.em (_after_allocation): New function.
2022-04-20 15:07:50 +01:00
Nick Clifton
65daf5bed6 Add linker warning for when it creates an executable stack.
PR 29072
2022-04-20 13:39:05 +01:00
GDB Administrator
5355776935 Automatic date update in version.in 2022-04-20 00:00:11 +00:00
GDB Administrator
a17a212139 Automatic date update in version.in 2022-04-19 00:00:19 +00:00
GDB Administrator
cd1a989fe1 Automatic date update in version.in 2022-04-18 00:00:16 +00:00
GDB Administrator
86416e21f2 Automatic date update in version.in 2022-04-17 00:00:14 +00:00
GDB Administrator
3beda815bd Automatic date update in version.in 2022-04-16 00:00:15 +00:00
GDB Administrator
64bc82adf3 Automatic date update in version.in 2022-04-15 00:00:12 +00:00
caiyinyu
e6f601b74d ld:LoongArch: Fix glibc fail: tst-audit25a/b.
bfd/

  * elfnn-loongarch.c: Add new func elf_loongarch64_hash_symbol.
2022-04-14 09:13:39 +08:00
GDB Administrator
a9703116de Automatic date update in version.in 2022-04-14 00:00:20 +00:00
Alexander von Gluck IV
f5e7605006 binutils: enable PE on 32bit haiku build
* config.bfd (x86-haiku): Add i386_pei_vec as a selectable format.
2022-04-13 14:58:22 +01:00
GDB Administrator
1b35e577c3 Automatic date update in version.in 2022-04-13 00:00:10 +00:00
GDB Administrator
5f437feef4 Automatic date update in version.in 2022-04-12 00:00:20 +00:00
GDB Administrator
2a722c6460 Automatic date update in version.in 2022-04-11 00:00:10 +00:00
GDB Administrator
f190d13c78 Automatic date update in version.in 2022-04-10 00:00:22 +00:00
Alan Modra
57594b6a75 Rearrange struct bfd_section a little
For better packing on 64-bit hosts.

	* section.c (struct bfd_section): Move next and prev field earlier.
	Move alignment_power later.
	(BFD_FAKE_SECTION): Adjust to suit.
	* bfd-in2.h: Regenerate.
2022-04-09 15:34:24 +09:30
GDB Administrator
680e019e5a Automatic date update in version.in 2022-04-09 00:00:16 +00:00
Nick Clifton
7d41169b6d Debug info for function in Windows PE binary on wrong instruction
PR 29038
	* coffgen.c (coff_find_nearest_line_with_names): Fix typo
	retrieving saved bias.
2022-04-08 16:04:22 +01:00
GDB Administrator
a32c49c6dd Automatic date update in version.in 2022-04-08 00:00:12 +00:00
Mark Harmstone
145667f8d9 Add support for COFF secidx relocations
bfd	* coff-i386.c (in_reloc_p): Add R_SECTION.
	(howto_table): Add R_SECTION.
	(coff_pe_i386_relocation_section): Add support for R_SECTION.
	(coff_i386_reloc_type_lookup): Add support for
	BFD_RELOC_16_SECCIDX.
	* coff-x86_64.c (in_reloc_p): Add R_SECTION.
	(howto_table): Add R_SECTION.
	(coff_pe_amd64_relocation_section): Add support for R_SECTION.
	(coff_amd64_reloc_type_lookup): Add support for
	BFD_RELOC_16_SECCIDX.
	* reloc.c: Add BFD_RELOC_16_SECIDX.
	* bfd-in2.h: Regenerate.
	* libbfd.h: Regenerate.

gas	* config/tc-i386.c (pe_directive_secidx): New function.
	(md_pseudo_table): Add support for secidx.
	(x86_cons_fix_new): Likewise.
	(tc_gen_reloc): Likewise.
	* expr.c (op_rank): Add O_secidx.
	* expr.h (operatorT): Likewise.
	* symbols.c (resolve_symbol_value): Add support for O_secidx.
	* testsuite/gas/i386/secidx.s: New test source file.
	* testsuite/gas/i386/secidx.d: New test driver file.
	* testsuite/gas/i386/i386.exp: Run new test.

include	* coff/i386.h: Define R_SECTION.
	* coff/x86_64.h: Likewise.

ld	* testsuite/ld-pe/secidx1.s: New test source file.
	* testsuite/ld-pe/secidx2.s: New test source file.
	* testsuite/ld-pe/secidx.d: New test driver file.
	* testsuite/ld-pe/secidx_64.d: New test driver file.
	* testsuite/ld-pe/pe.exp: Add new tests.
2022-04-07 14:47:17 +01:00
GDB Administrator
5f0b6b77f1 Automatic date update in version.in 2022-04-07 00:00:11 +00:00
GDB Administrator
ca028a46d5 Automatic date update in version.in 2022-04-06 00:00:09 +00:00
GDB Administrator
ef485e453a Automatic date update in version.in 2022-04-05 00:00:06 +00:00
GDB Administrator
cf78890fd4 Automatic date update in version.in 2022-04-04 00:00:06 +00:00
Alan Modra
9751574e09 Move microblaze relax info to target specific data
Target specific data shouldn't be put in struct bfd_section.

	* section.c (struct bfd_section): Delete relax and relax_count.
	(BFD_FAKE_SECTION): Adjust to suit.
	(struct relax_table): Move to..
	* elf32-microblaze.c (struct relax_table): ..here.
	(struct _microblaze_elf_section_data): New.
	(microblaze_elf_section_data): Define.
	(microblaze_elf_new_section_hook): New function.
	(bfd_elf32_new_section_hook): Define.
	(calc_fixup): Return a size_t.  Adjust to suit new location of
	relax and relax_count.
	(microblaze_elf_relax_section): Adjust to suit new location of
	relax and relax_count.  Make some variables size_t.
	* bfd-in2.h: Regenerate.
2022-04-03 21:34:53 +09:30
Alan Modra
924cf858c9 Revert commit 240d6706c6
PR 28592
	PR 15994
	PR 15935
	* dwarf2.c (lookup_address_in_line_info_table): Return bool rather
	than a range.
	(comp_unit_find_nearest_line): Likewise.  Return true if function
	info found without line info.
	(_bfd_dwarf2_find_nearest_line): Revert range handling code.
2022-04-03 20:56:17 +09:30
Alan Modra
2b2463e2b0 Regen bfd po/SRC-POTFILES.in 2022-04-03 20:56:17 +09:30
GDB Administrator
f1feb9c020 Automatic date update in version.in 2022-04-03 00:00:07 +00:00
GDB Administrator
25eb664374 Automatic date update in version.in 2022-04-02 00:00:06 +00:00
John Baldwin
b5c2367c3a Use pseudosections for NT_FREEBSD_X86_SEGBASES core dump notes.
This includes adding pseudosections when reading a core dump as well
as support for writing out a core dump note from a pseudosection.

bfd/ChangeLog:

	* elf-bfd.h (elfcore_write_x86_segbases): New.
	* elf.c (elfcore_grok_freebsd_note): Add pseudosections for
	NT_FREEBSD_X86_SEGBASES register notes.
	(elfcore_write_x86_segbases): New.
	(elfcore_write_register_note): Write NT_FREEBSD_X86_SEGBASES
	register notes.
2022-04-01 13:16:46 -07:00
John Baldwin
e330d4c033 elfcore_grok_freebsd_note: Remove checks of note->namesz.
This function is only called if the note name is "FreeBSD", so
checking the name size is unnecessary.

bfd/ChangeLog:

	* elf.c (elfcore_grok_freebsd_note): Remove checks for namesz.
2022-04-01 13:16:46 -07:00
H.J. Lu
801a7eab11 x86: Remove bfd_arch_l1om and bfd_arch_k1om
Remove bfd_arch_l1om and bfd_arch_k1om since L1OM/K1OM support has been
removed from gas, ld and opcodes.

bfd/

	* Makefile.am (ALL_MACHINES): Remove cpu-l1om.lo and cpu-k1om.lo.
	(ALL_MACHINES_CFILES): Remove cpu-l1om.c and cpu-k1om.c.
	* archures.c (bfd_mach_l1om): Removed.
	(bfd_mach_l1om_intel_syntax): Likewise.
	(bfd_mach_k1om): Likewise.
	(bfd_mach_k1om_intel_syntax): Likewise.
	(bfd_k1om_arch): Likewise.
	(bfd_l1om_arch): Likewise.
	(bfd_archures_list): Remove bfd_k1om_arch and bfd_l1om_arch
	references.
	* config.bfd (targ_selvecs): Remove l1om_elf64_vec.
	l1om_elf64_fbsd_vec, k1om_elf64_vec and k1om_elf64_fbsd_vec.
	(targ_archs): Remove bfd_l1om_arch and bfd_k1om_arch.
	* configure.ac (k1om_elf64_vec): Removed.
	(k1om_elf64_fbsd_vec): Likewise.
	(l1om_elf64_vec): Likewise.
	(l1om_elf64_fbsd_vec): Likewise.
	* cpu-k1om.c: Removed.
	* cpu-l1om.c: Likewise.
	* elf64-x86-64.c (elf64_l1om_elf_object_p): Removed.
	(elf64_k1om_elf_object_p): Likewise.
	(l1om_elf64_vec): Removed.
	(l1om_elf64_fbsd_vec): Likewise.
	(k1om_elf64_vec): Likewise.
	(k1om_elf64_fbsd_vec): Likewise.
	(ELF_TARGET_OS): Undefine.
	* targets.c (_bfd_target_vector): Remove k1om_elf64_vec,
	k1om_elf64_fbsd_vec, l1om_elf64_vec and l1om_elf64_fbsd_vec.
	* Makefile.in: Regenerate.
	* bfd-in2.h: Likewise.
	* configure: Likewise.

opcodes/

	* configure.ac: Remove bfd_arch_l1om/bfd_arch_k1om references.
	* disassemble.c (disassembler): Likewise.
	* configure: Regenerate.
2022-03-31 18:58:53 -07:00
GDB Administrator
d7abb2c4bd Automatic date update in version.in 2022-04-01 00:00:12 +00:00
GDB Administrator
07e9e57ca6 Automatic date update in version.in 2022-03-31 00:00:06 +00:00
GDB Administrator
c09115ad6e Automatic date update in version.in 2022-03-30 00:00:07 +00:00