Commit Graph

19462 Commits

Author SHA1 Message Date
Mark Wielaard
328f42d85b bfd: Remove unused static find function from doc/chew.c
After commit 2e60790cf7 "Remove the
paramstuff word" there is no caller left of the static find function
in doc/chew.c, so it should be removed.

* doc/chew.c (find): Remove.
2024-11-08 11:08:56 +01:00
GDB Administrator
01086f8a21 Automatic date update in version.in 2024-11-08 00:00:33 +00:00
GDB Administrator
8adee4d2ce Automatic date update in version.in 2024-11-07 00:00:53 +00:00
GDB Administrator
52a8387dfd Automatic date update in version.in 2024-11-06 00:00:43 +00:00
GDB Administrator
e1e4078ac5 Automatic date update in version.in 2024-11-05 00:00:32 +00:00
GDB Administrator
55e32b3c68 Automatic date update in version.in 2024-11-04 00:00:32 +00:00
GDB Administrator
69a9577358 Automatic date update in version.in 2024-11-03 00:00:17 +00:00
GDB Administrator
22d7506fb9 Automatic date update in version.in 2024-11-02 00:00:22 +00:00
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
GDB Administrator
893e4fd623 Automatic date update in version.in 2024-11-01 00:00:55 +00:00
GDB Administrator
4868f6025e Automatic date update in version.in 2024-10-31 00:00:21 +00:00
GDB Administrator
0a81e17f76 Automatic date update in version.in 2024-10-30 00:00:53 +00:00
Lulu Cai
287938873c LoongArch: Corrected to GNU style code 2024-10-29 15:56:52 +08:00
GDB Administrator
ad909bee05 Automatic date update in version.in 2024-10-29 00:00:56 +00:00
GDB Administrator
b391a8b043 Automatic date update in version.in 2024-10-28 00:00:27 +00:00
GDB Administrator
9af55b9568 Automatic date update in version.in 2024-10-27 00:00:22 +00:00
Alan Modra
b3ee98cda4 tekhex.c tidy writesym
Simplifies the code a little.  No functional changes.
2024-10-26 10:28:10 +10:30
GDB Administrator
be6d665abd Automatic date update in version.in 2024-10-25 00:00:31 +00:00
Alan Modra
8b5a212495 tekhex object file output fixes
writevalue didn't handle 64-bit values, dropping the high 32 bits,
and also wrote any value in the range [0,15] as 0.

	* tekhex.c (first_phase): Handle *ABS* symbols.
	(writevalue): Rewrite.
2024-10-24 17:58:00 +10:30
GDB Administrator
4598f83eac Automatic date update in version.in 2024-10-24 00:00:32 +00:00
GDB Administrator
538271a1e0 Automatic date update in version.in 2024-10-23 00:00:49 +00:00
Michael Matz
8483536dea stringmerge: don't presize hash table
originally the reason for pre-sizing was that that's easier
for a multi-threaded use of the hash table.  That hasn't materialized
yet, so there's not much sense in using the very very conservative
estimates for pre-sizing.  Doing the resize on-demand, whenever we
actually need to add a new entry doesn't change performance.

	bfd/
	merge.c (sec_merge_hash_insert): Resize as needed from here ...
	(record_section): ... not from here.  Don't calculate estimates,
	return bool instead of three-state, regard all errors as soft
	errors.
	(_bfd_merge_sections): Adjust.
2024-10-22 14:14:32 +02:00
Lulu Cai
3790b9f7ff LoongArch: Force relocation for every reference to the global offset table
Local absolute symbols are resolved at assembly stage and the symbol
value is placed in the relocation addend. But non-zero addend will
cause an assertion failure during linking.

Forces emission of relocations to defer resolution of local abs symbols
until link time.

bfd/

        * elfnn-loongarch.c (loongarch_elf_relax_section): Determine
          absolute symbols in advance to avoid ld crash.

gas/

        * config/tc-loongarch.c (loongarch_force_relocation): New
          function to force relocation.
        * config/tc-loongarch.h (TC_FORCE_RELOCATION): New macros
          to force relocation.
        (loongarch_force_relocation): Function declaration.
        * testsuite/gas/loongarch/localpic.d: New test.
        * testsuite/gas/loongarch/localpic.s: New test.
2024-10-22 12:01:41 +08:00
GDB Administrator
4806ed93bc Automatic date update in version.in 2024-10-22 00:00:23 +00:00
GDB Administrator
0740c33685 Automatic date update in version.in 2024-10-21 00:00:24 +00:00
Alan Modra
32dc367249 Report bfd_merge_sections error
PR 32260
bfd/
	* elfxx-target.h (bfd_elfNN_bfd_merge_sections): Default to
	bfd_generic_merge_sections when using the generic linker.
	* elflink.c (_bfd_elf_merge_sections): Return error from
	_bfd_merge_sections.  Abort on wrong hash table.
ld/
	* ldlang.c (lang_process): Report bfd_merge_sections error.
2024-10-20 17:15:53 +10:30
GDB Administrator
17b145510f Automatic date update in version.in 2024-10-20 00:00:20 +00:00
GDB Administrator
f4b00218b5 Automatic date update in version.in 2024-10-19 00:00:25 +00:00
GDB Administrator
0e15fd3d54 Automatic date update in version.in 2024-10-18 00:00:30 +00:00
Michael Matz
22ae2e1f70 Fix for -Wstringop-overflow false positive
the way the overflow check was written wasn't understood by some
GCC versions and produced false positives for the memset call being
called potentially with object sizes that are larger than half
address-space.
2024-10-17 17:44:29 +02:00
Michael Matz
ed3228de9b PR32260: Improve error handling on string merging
if the input sections are near the max supported size (4G)
we might fail to enlarge the hash table.  The error handling
for this case didn't quite work.  When this happens we can
gracefully fall back to just not deduplicate this section
(and continue with further mergable sections).  We were mixing
that with the case of not being able to even allocate a small
structure (in which case we can as well error out completely),
this disentables both cases.

	bfd/

	PR ld/32260
	* merge.c (sec_merge_maybe_resize): Check overflow in ultimate
	target type.
	(record_section): Return three-state, use new state when unable
	to enlarge hash table.
	(_bfd_merge_sections): Remove current section from merging
	consideration when hashtable can't be enlarged.
2024-10-17 16:41:37 +02:00
Lulu Cai
4cb77761d6 LoongArch: Check PC-relative relocations for shared libraries
Building shared libraries should not be allowed for PC-relative
relocations against external symbols.
Currently LoongArch has no corresponding checks and silently
generates wrong shared libraries.

However, In the first version of the medium cmodel, pcalau12i+jirl was
used for function calls, in which case PC-relative relocations were
allowed.
2024-10-17 21:01:52 +08:00
GDB Administrator
320601c9ac Automatic date update in version.in 2024-10-17 00:00:25 +00:00
Alan Modra
02d1e73bf6 Assertion fail at peicode.h:607
This is the assertion that vars->string_ptr < vars->end_string_ptr,
ie. when it fails we've overflowed the string buffer area.  Caused by
allocating space for import_name but writing symbol_name, and they can
be different.

	* peicode.h (SIZEOF_ILF_STRINGS): Revert 042f14505e change.
2024-10-16 16:02:05 +10:30
Alan Modra
76eab8f47a PR32266, segv when linking libclang_rt.asan-powerpc64.so
Change the mmap support added with commit 9ba56acee5 to always mmap
memory with PROT_READ | PROT_WRITE.  Prior to that commit most file
contents were read into a buffer allocated with bfd_alloc or
bfd_malloc and thus the memory was read/write.  Even after that commit
any section contents with relocations must be read/write to apply the
relocs.  Making them all read/write is not a major change, and it
should not introduce any measurable linker slowdown for contents that
are not modified.  More importantly, it removes a BFD behaviour
difference that only triggers when large files are involved.

	PR 32266
	PR 32109
	* libbfd.c (bfd_mmap_local): Remove prot param.  Always mmap
	with PROT_READ | PROT_WRITE.  Adjust all calls.
	(_bfd_mmap_temporary): Rename from _bfd_mmap_readonly_temporary.
	(_bfd_munmap_temporary): Rename from _bfd_munmap_readonly_temporary.
	_bfd_mmap_persistent): Rename from _bfd_mmap_readonly_persistent.
	(_bfd_generic_get_section_contents): Use PROT_READ | PROT_WRITE
	regardless of relocs.
	* libbfd-in.h: Update decls to suit.  Make non-USE_MMAP variants
	static inline functions.
	* elflink.c: Update all uses of _bfd_mmap functions.
	* elf.c: Likewise.
	(bfd_elf_get_str_section): Revert commit 656f8fbaae.
	* libbfd.h: Regenerate.
2024-10-16 14:23:27 +10:30
GDB Administrator
6f4024f86d Automatic date update in version.in 2024-10-16 00:00:19 +00:00
mengqinggang
a104f0a3e6 LoongArch: Add more relaxation support for call36
Add relaxation support for call36 that jump to PLT entry.

Add relaxation support for call36 with IFUNC symbol.

Add relaxation support for call36 that jump to undefweak symbol.
For undefweak symbol, it can always be relaxed if it have no PLT entry.
Because we set the address of undefweak symbol without PLT entry to PC
like relocate_section.
2024-10-15 14:26:17 +08:00
mengqinggang
5c3d09c185 LoongArch: Optimize the relaxation process
The symbol value is only calculated when the relocation can be relaxed.
2024-10-15 14:26:11 +08:00
GDB Administrator
60bee7c28e Automatic date update in version.in 2024-10-15 00:00:20 +00:00
GDB Administrator
a134ad4780 Automatic date update in version.in 2024-10-14 00:00:16 +00:00
GDB Administrator
df89bdf0ba Automatic date update in version.in 2024-10-13 00:00:15 +00:00
GDB Administrator
cd55846db3 Automatic date update in version.in 2024-10-12 00:00:09 +00:00
Jan Beulich
29ed50151a bfd/ELF: drop align_file_position()
Switch the sole user to BFD_ALIGN() instead. (It's comment was partly
wrong [stale?] anyway, talking of some maximum that was nowhere in
sight.)
2024-10-11 08:20:06 +02:00
Jan Beulich
1f1b5e506b bfd/ELF: restrict file alignment for object files
While for executables properly aligning sections within the file can be
quite relevant, the same is of pretty little importance for relocatable
object files. Avoid passing "true" into
_bfd_elf_assign_file_position_for_section() when dealing with object
files, but compensate minimally by applying log_file_align in such
cases as a cap to the alignment put in place.
2024-10-11 08:19:34 +02:00
GDB Administrator
7fbaef8e80 Automatic date update in version.in 2024-10-11 00:00:42 +00:00
GDB Administrator
1f0bc051ac Automatic date update in version.in 2024-10-10 00:00:20 +00:00
GDB Administrator
df475bd532 Automatic date update in version.in 2024-10-09 00:00:41 +00:00
Alan Modra
124deb3101 Revised "Don't return (null) from bfd_elf_sym_name"
Commit 68bbe11833 results in a lot of follow up work, much of which
likely is still to be done. (And yes, since this is all for corrupted
or fuzzed object files, a whole lot of work doesn't much benefit
anyone.  It was a bad idea to put NULL in asymbol->name.)  So I'm
changing the approach to instead put a unique empty string for symbols
with a corrupted st_name.  An empty string won't require much work to
ensure nm, objcopy, objdump etc. won't crash, since these tools
already must work with unnamed local symbols.

The unique empty string is called bfd_symbol_error_name.  This patch
uses that name string for corrupted symbols in the ELF and COFF
backends.  Such symbols are displayed by nm and objdump as the
translated string "<corrupt>", which is what the COFF backend used to
put directly into corrupted symbols.

ie. it's the way I should have written the original patch, plus a few
tides and cleanups I retained from the reverted patches.
2024-10-08 15:12:19 +10:30