Age | Commit message (Collapse) | Author | Files | Lines |
|
binutils/ChangeLog
2025-06-29 Vladimir Mezentsev <vladimir.mezentsev@oracle.com>
* dwarf.c: Change "/usrlib64/debug/usr" to "/usr/lib64/debug/usr/" and
.gun_debugaltlink to .gnu_debugaltlink.
|
|
Change
verbose "cmp tmpdir/pr27708.out $srcdir/$subdir/pr26808.dump" 1
to
verbose "cmp tmpdir/pr27708.out $srcdir/$subdir/pr27708.dump" 1
* testsuite/binutils-all/x86-64/x86-64.exp: Correct pr26808.dump
to pr27708.dump.
Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
|
|
Disclaimer: this issue cannot occur with Object Attributes v1 (OAv1) while
using the GNU binutils because a value of '\0' (empty string) for a tag
with a string value is considered as the default value for the attribute,
and consequently is eliminated by gas from the output object file during
the serialization.
An empty string is a valid value for a NTBS tag in both OAv1 and OAv2 [1]
cases. However, contrarily to OAv1, a OAv2 subsection can be required and
so, tags in this subsection might have to be present even if the value is
the default. To comply with this requirement, the OAv2 serializer won't
drop the default values.
In the case where a NTBS tag has the value '\0' and is last in the object
attributes section, the current code in readelf used for dumping the object
attributes incorrectly detects an overflow, and prints out an error message
for a corrupted string tag.
This patch fixes the detection of the overflow so that it now accept an
empty string in the last tag of the object attributes section.
It also fixes the previous tests for the empty NTBS case and the non-null
terminated string one. The fix was also tested in the context of OAv2's
patch series [1] where the issue was originally detected. No regression
was found.
[1]: https://inbox.sourceware.org/binutils/20250509151319.88725-1-matthieu
.longo@arm.com/
|
|
|
|
GNU_PROPERTY_RISCV_FEATURE_1_CFI_LP_UNLABELED
This patch adds two new GNU properties for RISC-V:
GNU_PROPERTY_RISCV_FEATURE_1_CFI_SS and GNU_PROPERTY_RISCV_FEATURE_1_CFI_LP_UNLABELED.
We only add readelf and define the properties in this patch.
Ref: https://github.com/riscv-non-isa/riscv-elf-psabi-doc/pull/417
|
|
Since the output section contents are copied from the input, don't
extend the output section size beyond the input section size.
PR binutils/33049
* objcopy.c (copy_section): Don't extend the output section
size beyond the input section size.
Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
|
|
commit 717a38e9a02109fcbcb18bb2ec3aa251e2ad0a0d
Author: H.J. Lu <hjl.tools@gmail.com>
Date: Sun May 4 05:12:46 2025 +0800
strip: Add GCC LTO IR support
added:
@@ -3744,6 +3768,12 @@ copy_archive (bfd *ibfd, bfd *obfd, const char
*output_target,
goto cleanup_and_exit;
}
+#if BFD_SUPPORTS_PLUGINS
+ /* Copy LTO IR file as unknown object. */
+ if (bfd_plugin_target_p (ibfd->xvec))
^^^^ A typo, should be this_element.
+ ok_object = false;
+ else
+#endif
if (ok_object)
{
ok = copy_object (this_element, output_element, input_arch);
to check if the archive element is a LTO IR file. "ibfd" is the archive
BFD. "this_element" should be used to check for LTO IR in the archive
element. Fix it by replacing "ibfd" with "this_element".
PR binutils/33078
* objcopy.c (copy_archive): Correctly check archive element for
LTO IR.
* testsuite/binutils-all/objcopy.exp (strip_test_archive): New.
Run strip_test_archive.
Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
|
|
Noticed the extra zeros while inspecting the output.
Signed-off-by: Jeremy Drake <sourceware-bugzilla@jdrake.com>
|
|
This allows the delay IAT to be in its own section with nothing else, as
required by IMAGE_GUARD_DELAYLOAD_IAT_IN_ITS_OWN_SECTION, documented at
https://learn.microsoft.com/en-us/windows/win32/debug/pe-format#load-configuration-layout
Signed-off-by: Jeremy Drake <sourceware-bugzilla@jdrake.com>
|
|
A delay-import symbol (of a function) is resolved when a call to it is made.
The delay loader may overwrite the `__imp_` pointer to the actual function
after it has been resolved, which requires the pointer itself be in a
writeable section.
Previously it was placed in the ordinary Import Address Table (IAT), which
is emitted into the `.idata` section, which had been changed to read-only
in db00f6c3aceabbf03acdb69e74b59b2d2b043cd7, which caused segmentation
faults when functions from delay-import library were called. This is
PR 32675.
This commit makes DLLTOOL emit delay-import IAT into `.didat`, as specified
by Microsoft. Most of the code is copied from `.idata`, except that this
section is writeable. As a side-effect of this, PR 14339 is also fixed.
Using this DEF:
```
; ws2_32.def
LIBRARY "WS2_32.DLL"
EXPORTS
WSAGetLastError
```
and this C program:
```
// delay.c
#define WIN32_LEAN_AND_MEAN 1
#include <windows.h>
#include <stdio.h>
/////////////////////////////////////////////////////////
// User code
/////////////////////////////////////////////////////////
DWORD WINAPI WSAGetLastError(void);
extern PVOID __imp_WSAGetLastError;
int
main(void)
{
fprintf(stderr, "before delay load, __imp_WSAGetLastError = %p\n", __imp_WSAGetLastError);
SetLastError(123);
fprintf(stderr, "WSAGetLastError() = %d\n", WSAGetLastError());
fprintf(stderr, "after delay load, __imp_WSAGetLastError = %p\n", __imp_WSAGetLastError);
__imp_WSAGetLastError = (PVOID) 1234567;
fprintf(stderr, "after plain write, __imp_WSAGetLastError = %p\n", __imp_WSAGetLastError);
}
/////////////////////////////////////////////////////////
// Overridden `__delayLoadHelper2` facility
/////////////////////////////////////////////////////////
extern char __ImageBase[];
PVOID WINAPI ResolveDelayLoadedAPI(PVOID ParentModuleBase, LPCVOID DelayloadDescriptor,
PVOID FailureDllHook, PVOID FailureSystemHook,
FARPROC* ThunkAddress, ULONG Flags);
FARPROC WINAPI DelayLoadFailureHook(LPCSTR name, LPCSTR function);
FARPROC WINAPI __delayLoadHelper2(LPCVOID pidd, FARPROC* ppfnIATEntry)
{
return ResolveDelayLoadedAPI(&__ImageBase, pidd, NULL, (PVOID) DelayLoadFailureHook,
ppfnIATEntry, 0);
}
```
This program used to crash:
```
$ dlltool -nn -d ws2_32.def -y delay_ws2_32.a
$ gcc -g delay.c delay_ws2_32.a -o delay.exe
$ ./delay.exe
before delay load, __imp_WSAGetLastError = 00007FF6937215C6
Segmentation fault
```
After this commit, it loads and calls `WSAGetLastError()` properly, and
`__imp_WSAGetLastError` is writeable:
```
$ dlltool -nn -d ws2_32.def -y delay_ws2_32.a
$ gcc -g delay.c delay_ws2_32.a -o delay.exe
$ ./delay.exe
before delay load, __imp_WSAGetLastError = 00007FF76E2215C6
WSAGetLastError() = 123
after delay load, __imp_WSAGetLastError = 00007FFF191FA720
after plain write, __imp_WSAGetLastError = 000000000012D687
```
Reference: https://learn.microsoft.com/en-us/windows/win32/secbp/pe-metadata#import-handling
Co-authored-by: Jeremy Drake <sourceware-bugzilla@jdrake.com>
Signed-off-by: LIU Hao <lh_mouse@126.com>
Signed-off-by: Jeremy Drake <sourceware-bugzilla@jdrake.com>
|
|
This is a followup to commt 619f863c55ca "dlltool memory leaks".
The name passed to def_name is freed, so if missing we can't just
use "". strdup it.
* defparse.y (opt_name): xstrdup empty string.
|
|
|
|
PR 33024
PR 33025
* elfedit.c (update_gnu_property): Sanity check program headers.
|
|
* objdump.c (disassemble_data): Free modified xvec and replace
original.
|
|
Texinfo 7.2 began showing warnings like:
binutils.texi:882: warning: do not set .info suffix in reference for manual `ld.info'
binutils.texi:1365: warning: do not set .info suffix in reference for manual `ld.info'
The Texinfo developers plan to stop removing the '.info' suffix
internally in a future release so without this patch the references will
break in the future.
Signed-off-by: Collin Funk <collin.funk1@gmail.com>
|
|
When all LTO sections have been removed, the BFD lto_type is set to
lto_non_ir_object by bfd_set_lto_type. In this case, don't complain
needing a plugin when seeing a LTO slim symbol.
bfd/
PR binutils/32967
* archive.c (_bfd_compute_and_write_armap): Call
bfd_lto_slim_symbol_p to check LTO slim symbol.
* bfd-in2.h: Generated.
* bfd.c (bfd_lto_slim_symbol_p): New.
binutils/
PR binutils/32967
* nm.c (filter_symbols): Call bfd_lto_slim_symbol_p to check
LTO slim symbol.
ld/
PR binutils/32967
* testsuite/ld-plugin/lto-binutils.exp: Run PR binutils/32967
tests.
* testsuite/ld-plugin/strip-1a-s-all.nd: New file.
Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
|
|
Fix three place where a NULL could be passed to "toosmall".
|
|
Marcus has resigned from the project.
|
|
|
|
Add GCC LTO IR support to strip by copying GCC LTO IR input as unknown
object file. Don't enable LTO plugin in strip unless all LTO sections
should be removed, assuming all LTO sections will be removed with
-R .gnu.lto_.*. Add linker LTO tests for strip with --strip-unneeded
and GCC LTO IR inputs.
binutils/
PR binutils/21479
* objcopy.c: Include "plugin-api.h" and "plugin.h".
(lto_sections_removed): New.
(command_line_switch): Add OPTION_PLUGIN.
(strip_options): Likewise.
(strip_usage): Display "--plugin NAME".
(copy_unknown_file): New function.
(copy_unknown_object): Call copy_unknown_file.
(copy_archive): Copy input LTO IR member as unknown object.
(copy_file): Set input target to "plugin" for strip if it is
unset unless all LTO sections should be removed. Copy input
LTO IR file as unknown file.
(strip_main): Call bfd_plugin_set_program_name. Handle
OPTION_PLUGIN. Set lto_sections_removed to true if all GCC
LTO sections should be removed.
* doc/binutils.texi: Document --plugin for strip.
ld/
PR binutils/21479
* testsuite/ld-plugin/lto-binutils.exp: New file.
* testsuite/ld-plugin/strip-1a-fat.c: Likewise.
* testsuite/ld-plugin/strip-1a-fat.rd: Likewise.
* testsuite/ld-plugin/strip-1b-fat.c: Likewise.
* testsuite/ld-plugin/strip-1b-fat.rd: Likewise.
* testsuite/ld-plugin/strip-1a.c: Likewise.
* testsuite/ld-plugin/strip-1b.c: Likewise.
* testsuite/lib/ld-lib.exp (run_cc_link_tests): Add optional
trailing ld options.
Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
|
|
Update my email address and move up Surya's name as the main PPC contact.
Signed-off-by: Peter Bergner <bergner@tenstorrent.com>
|
|
This patch support RISC-V Privileged Architecture 1.13 CSRs 'medelegh' and
'hedelegh'. More details between 1.12 and 1.13 see [1].
[1] https://github.com/riscv/riscv-isa-manual/blob/main/src/priv-preface.adoc
Version log: Remove gas/po changes.
bfd/ChangeLog:
* cpu-riscv.c: New option.
* cpu-riscv.h (enum riscv_spec_class): Ditto.
binutils/ChangeLog:
* doc/binutils.texi: New option.
gas/ChangeLog:
* NEWS: Add priv-1.13 support.
* config/tc-riscv.c: New option.
* configure: Ditto.
* configure.ac: Ditto.
* testsuite/gas/riscv/csr-version-1p10.d: New CSR.
* testsuite/gas/riscv/csr-version-1p10.l: New warning.
* testsuite/gas/riscv/csr-version-1p11.d: New CSR.
* testsuite/gas/riscv/csr-version-1p11.l: New warning.
* testsuite/gas/riscv/csr-version-1p12.d: New CSR.
* testsuite/gas/riscv/csr-version-1p12.l: New warning.
* testsuite/gas/riscv/csr.s: New CSR.
* testsuite/gas/riscv/attribute-15.d: New test.
* testsuite/gas/riscv/attribute-16.d: New test.
* testsuite/gas/riscv/csr-version-1p13.d: New test.
* testsuite/gas/riscv/csr-version-1p13.l: New test.
include/ChangeLog:
* opcode/riscv-opc.h (CSR_MEDELEGH): New CSR.
(CSR_HEDELEGH): Ditto.
(DECLARE_CSR): Ditto.
|
|
bin_to_res_menuexitems can be called with random data offsets (and thus
remaining lengths), confusing code that expects 4-byte aligned data.
Prevent an item length adjustment for alignment exceeding the
remaining length and then overflowing.
|
|
windres_get_32 and similar have a length parameter that in most cases
is just the required length, so it is redundant. The few cases where
a variable length is passed are all in resrc.c. So, get rid of the
length parameter and introduce wrappers in resrc.c to check the
length.
|
|
There's no reason to reject this common COFF directive when it doesn't
have any other meaning.
|
|
Don't warn if the offset of the first entry in .debug_rnglists starts
right after the header. Warn holes in .debug_ranges and debug_rnglists
sections only if the last end pointer isn't the same as the current
start pointer.
PR binutils/32927
* dwarf.c (display_debug_ranges_list): Return the pointer to the
end.
(display_debug_ranges): Don't warn if the offset of the first
entry in .debug_rnglists starts right after the header. Warn a
hole only if the last end pointer is the same as the next pointer.
* testsuite/binutils-all/x86-64/dwarf4.s: New file.
* testsuite/binutils-all/x86-64/dwarf5.s: Likewise.
* testsuite/binutils-all/x86-64/pr32927-1.d: Likewise.
* testsuite/binutils-all/x86-64/pr32927-2.d: Likewise.
Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
Co-Authored-By: Alan Modra <amodra@gmail.com>
|
|
.debug_loclists section is loaded into debug_information as DWARF-5 debug
info and .debug_loc section is loaded into debug_information as pre-DWARF-5
debug info. When dumping .debug_loc section, we should only process
pre-DWARF-5 debug info in debug_information. When dumping .debug_loclists
section, we should only process DWARF-5 info in debug_information.
binutils/
PR binutils/32809
* dwarf.c (display_debug_loc): Dump .debug_loclists only for
DWARF-5.
ld/
PR binutils/32809
* testsuite/ld-x86-64/dwarf4.s: New file.
* testsuite/ld-x86-64/dwarf5a.s: Likewise.
* testsuite/ld-x86-64/dwarf5b.s: Likewise.
* testsuite/ld-x86-64/pr32809.d: Likewise.
* testsuite/ld-x86-64/x86-64.exp: Run pr32809.
Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
|
|
binutils/
* MAINTAINERS: Add myself as PPC maintainer.
|
|
Also free malloc'd relocs.
|
|
* rescoff.c (read_coff_res_dir): Add more sanity checking.
Tidy and correct existing checks.
|
|
Also remove unnecessary casts on memory alloc function returns.
|
|
Commit 9e68cae4fdfb broke the check I added in commit 4846e543de95.
Add missing "return NULL".
|
|
The flag already exists but it's not been exposed to user.
Signed-off-by: Marek Pikuła <m.pikula@partner.samsung.com>
|
|
windres code has the habit of exiting on any error. That's not so
bad, but it does make oss-fuzz ineffective when testing windres. Fix
many places that print errors and exit to instead print the error and
pass status up the call chain. In the process of doing this, I
noticed write_res_file was calling bfd_close without checking return
status. Fixing that resulted in lots of testsuite failures. The
problem was a lack of bfd_set_format in windres_open_as_binary, which
leaves the output file as bfd_unknown format. As it happens this
doesn't make any difference in writing the output binary file, except
for the bfd_close return status.
|
|
oss-fuzz testcase manages to hit a buffer overflow. Sanity check
by passing the buffer length to bin_to_res_toolbar and ensuring reads
don't go off the end of the buffer.
|
|
Size being set for a symbol isn't a strict requirement in ELF. For ones
not having their size set, fall back to the same logic as used for non-
ELF, non-COFF symbols.
While there switch to using elf_symbol_from() instead of kind of open-
coding it.
|
|
Like ELF for all symbols, COFF can record size for at least function
ones. Use that - if available - in preference to the distance-to-next-
symbol heuristic.
To be able to use the new test there, make TI C54x follow TI C4x in
providing .sdef to cover for .def already having different meaning.
|
|
... to be a power of two, just like --section-alignment does.
|
|
There's no reason to limit this to just ELF. TI C30 and Z8k don't encode
section alignment in the section entries though (which can't be quite
right, or there would need to be another means by which to express
alignment needs), so --set-section-alignment simply has no effect there.
|
|
PR binutils/32732
The --set-section-alignment option is what ought to be used on object
files; --section-alignment should be affecting PE binaries only, and
only the value stored in the header. Sections don't individually have
alignment recorded there; see 6f8f6017a0c4 ("PR27567, Linking PE files
adds alignment section flags to executables").
Undo the core part of 121a3f4b4f4a ("Update objcopy's
--section-alignment option so that it sets the alignment flag on..."),
which includes removing the testcase again, while leaving all secondary
changes in place. (Note that the testcase did fail anyway for
i?86-interix, with objdump saying "option -P/--private not supported by
this file".)
|
|
With it only being the tail of the name which wants checking, using
lbasename() isn't helpful. Mirror what objcopy.c:main() does to ar.c,
merely chaning the plain int of the local variable to size_t.
|
|
By not linking the exact same object file twice, in particular ranlib can
benefit quite a bit from the compiler eliminating dead code.
|
|
By not linking the exact same object file twice, in particular strip can
benefit quite a bit from the compiler eliminating dead code.
|
|
u.kenum is always non-NULL, see debug_make_enum_type.
PR 32829
* debug.c (debug_type_samep): Correct incomplete enum test.
(debug_write_type): Remove dead code.
|
|
The output file could be created before the input is gathered by tail,
erasing the later before it's being proceeded.
This happened on rare cases when performing remote tests on
Ubuntu 24.04.
|
|
"objdump.out" is a testsuite trace and thus should be created within the
tmpdir.
|
|
Up to this point, no mention of RISC-V-specific disassembler options was
mentioned in binutils documentation. This patch includes description for
all of the currently supported options.
Signed-off-by: Marek Pikuła <m.pikula@partner.samsung.com>
|
|
Turns out the return value of parse_loongarch_dis_option acts as an
error code, and previously the function always signified failure with
a non-zero return value, making only the first disassembly option get
to take effect.
Fix by adding the missing `return 0`'s to the two success code paths.
Signed-off-by: WANG Xuerui <git@xen0n.name>
|
|
Section and file alignment are supposed to remain unaltered when PE
binaries are stripped. While this is the case when they're strip-ed
individually, passing multiple such files to strip would reset the
two values to their defaults in all but the first of those binaries.
|
|
|