Alan Modra
e416bd75c3
warn unused result for bfd IO functions
...
This patch fixes all the warnings I found in bfd, binutils and ld,
plus some bitrotted COFF_GO32 code that tried to allocate -168ul
bytes. When the malloc fail was reported these testsuite fails
resulted:
i386-go32 +FAIL: go32 stub
i386-go32 +ERROR: tcl error sourcing /home/alan/src/binutils-gdb/ld/testsuite/ld-i386/i386.exp.
i386-go32 +ERROR: couldn't open "tmpdir/go32stub": no such file or directory
i386-go32 +FAIL: ld-scripts/sane1
i386-go32 +FAIL: ld-scripts/assign-loc
i386-go32 +FAIL: ld-scripts/pr18963
This does result in some warnings in gdb which are fixed in a followup
patch.
bfd/
* bfdio.c (bfd_read, bfd_write): Add ATTRIBUTE_WARN_UNUSED_RESULT.
(bfd_tell, bfd_stat, bfd_seek, bfd_mmap): Likewise.
* bfd-in2.h: Regenerate.
* coff-rs6000.c (xcoff_write_armap_big) Don't ignore bfd_write
return value.
(xcoff_generate_rtinit): Likewise. Also free data_buffer and
string_table before returning.
* coff64-rs6000.c (xcoff64_generate_rtinit): Likewise.
* coff-stgo32.c (go32exe_check_format): Don't ignore bfd_seek
return value.
* coffcode.h (coff_apply_checksum): Don't ignore bfd_write return.
(coff_write_object_contents <COFF_GO32>): Likewise, and bfd_malloc.
Fix bitrotted code to look for first section with non-zero filepos.
* elf64-ia64-vms.c (elf64_vms_write_shdrs_and_ehdr): Don't ignore
bfd_seek or bfd_write return values.
* pef.c (bfd_pef_scan_section): Likewise.
(bfd_pef_read_header, bfd_pef_xlib_read_header): Likewise.
* vms-misc.c (_bfd_vms_output_end): Likewise. Return status.
* vms.h (_bfd_vms_output_end): Update prototype.
* vms-alpha.c: Pass _bfd_vms_output_end status up call chains.
* wasm-module.c (wasm_compute_custom_section_file_position): Don't
ignore bfd_seek or bfd_write return values.
(wasm_compute_section_file_positions): Likewise.
* xsym.c (bfd_sym_scan): Don't ignore bfd_seek return value.
(bfd_sym_read_name_table): Likewise.
binutils/
* ar.c (print_contents, extract_file): Don't ignore bfd_seek
return value.
ld/
* pdb.c (create_section_contrib_substream): Don't ignore bfd_seek
return value.
(create_section_header_stream): Likewise.
* pe-dll.c (pe_get16, pe_get32): Add fail param to return results
from bfd_seek and bfd_read.
(pe_implied_import_dll): Handle these fails, and other bfd_seek
and bfd_read return values.
2023-08-11 16:36:11 +09:30
Alan Modra
226f9f4fad
Rename bfd_bread and bfd_bwrite
...
These were renamed from bfd_read and bfd_write back in 2001 when they
lost an unnecessary parameter. Rename them back, and get rid of a few
casts that are only needed without prototyped functions (K&R C).
2023-08-09 08:48:09 +09:30
Jan Beulich
eb70d820e8
ld/PDB: fix off-by-1 in add_globals_ref()
...
Copying one too many bytes can corrupt memory, detected/reported by
glibc on a 32-bit distro.
2023-07-11 08:14:57 +02:00
Mark Harmstone
38395c77d7
ld: Sort section contributions in PDB files
...
Microsoft's DIA library, and thus also MSVC and WinDbg, expects section
contributions to be ordered by section number and offset, otherwise it's
unable to resolve line numbers.
2023-02-28 00:28:26 +00:00
Mark Harmstone
9a02fbd198
ld: Add pdb support to aarch64-w64-mingw32
...
This extends PDB support to the aarch64 PE targets.
The changes to the test files are just to make it so they can be assembled as
either x86, x86_64, or aarch64, mainly by changing the comment style.
The only actual code change here is in adding the architecture constants
to pdb.c.
2023-01-25 22:26:18 +00:00
Alan Modra
d87bef3a7b
Update year range in copyright notice of binutils files
...
The newer update-copyright.py fixes file encoding too, removing cr/lf
on binutils/bfdtest2.c and ld/testsuite/ld-cygwin/exe-export.exp, and
embedded cr in binutils/testsuite/binutils-all/ar.exp string match.
2023-01-01 21:50:11 +10:30
Mark Harmstone
5c9e42e0e9
ld: Handle LF_VFTABLE types in PDBs
2022-12-31 19:26:23 +10:30
Mark Harmstone
fdf591c4c6
ld: Handle extended-length data structures in PDB types
...
A few fixes to minor issues I've discovered in my PDB patches.
* If sizes or offsets are greater than 0x8000, they get encoded as
extended values in the same way as for enum values - e.g. a LF_ULONG
.short followed by a .long.
* I've managed to coax MSVC to produce another type, LF_VFTABLE, which
is seen when dealing with COM. I don't think LLVM emits this. Note that
we can't just implement everything in Microsoft's header files, as most
of it is obsolete.
* Fixes a stupid bug in the test program, where I was adding an index to
a size. The index was hard-coded to 0, so this didn't cause any actual
issues.
2022-12-31 19:26:23 +10:30
Mark Harmstone
8d25f5ef2c
ld: Write linker symbols in PDB
2022-12-23 21:10:09 +10:30
Mark Harmstone
5d9c033689
ld: Copy other symbols into PDB file
2022-12-23 21:02:21 +10:30
Mark Harmstone
81814b6f5b
ld: Write globals stream in PDB
2022-12-23 20:54:40 +10:30
Mark Harmstone
817840046a
ld: Parse LF_UDT_SRC_LINE records when creating PDB file
2022-12-23 20:45:30 +10:30
Mark Harmstone
fca9096a94
ld: Write types into IPI stream of PDB
2022-12-23 20:13:31 +10:30
Mark Harmstone
d5b4c0ddb9
ld: Write types into TPI stream of PDB
2022-12-23 20:05:48 +10:30
Mark Harmstone
598c1ae610
ld: Write DEBUG_S_LINES entries in PDB file
2022-12-23 19:57:56 +10:30
Mark Harmstone
8b182dc3c6
ld: Fix segfault in populate_publics_stream
2022-12-23 19:49:47 +10:30
Mark Harmstone
803561cb74
ld: Write DEBUG_S_FILECHKSMS entries in PDBs
2022-12-23 19:37:57 +10:30
Mark Harmstone
f559276dc5
ld: Generate PDB string table
2022-12-23 19:37:44 +10:30
Mark Harmstone
e2a1b0a0d1
ld: Add section contributions substream to PDB files
2022-11-23 01:13:35 +00:00
Mark Harmstone
5967ca921c
ld: Add module information substream to PDB files
2022-11-10 04:50:43 +00:00
Mark Harmstone
0882710510
ld: Add publics stream to PDB files
2022-10-31 12:57:26 +10:30
Mark Harmstone
a726722240
ld: Add section header stream to PDB files
2022-10-31 12:57:26 +10:30
Mark Harmstone
3c5e7c6dfc
ld: Use %E in einfo in pdb.c
...
Resubmission, taking into account
https://sourceware.org/pipermail/binutils/2022-October/123948.html .
2022-10-31 12:57:26 +10:30
Mark Harmstone
b41a65333f
ld: Add minimal pdb generation
2022-10-20 15:22:37 +10:30