readelf: Reset file position to beginning for thin archive members
* readelf.c (process_archive): Reset file position to the beginning when calling process_object for thin archive members. * testsuite/binutils-all/readelf.exp: Add test. * testsuite/binutils-all/readelf.h.thin: New file.
This commit is contained in:
parent
417f991f08
commit
75a2da57a1
4 changed files with 60 additions and 0 deletions
|
@ -1,3 +1,10 @@
|
||||||
|
2021-07-01 Andrei Homescu <ah@immunant.com>
|
||||||
|
|
||||||
|
* readelf.c (process_archive): Reset file position to the
|
||||||
|
beginning when calling process_object for thin archive members.
|
||||||
|
* testsuite/binutils-all/readelf.exp: Add test.
|
||||||
|
* testsuite/binutils-all/readelf.h.thin: New file.
|
||||||
|
|
||||||
2021-06-30 Tom Tromey <tom@tromey.com>
|
2021-06-30 Tom Tromey <tom@tromey.com>
|
||||||
|
|
||||||
* dwarf.c (read_and_display_attr_value): Handle
|
* dwarf.c (read_and_display_attr_value): Handle
|
||||||
|
|
|
@ -21792,6 +21792,9 @@ process_archive (Filedata * filedata, bool is_thin_archive)
|
||||||
filedata->archive_file_offset = arch.nested_member_origin;
|
filedata->archive_file_offset = arch.nested_member_origin;
|
||||||
member_filedata->file_name = qualified_name;
|
member_filedata->file_name = qualified_name;
|
||||||
|
|
||||||
|
/* The call to process_object() expects the file to be at the beginning. */
|
||||||
|
rewind (member_filedata->handle);
|
||||||
|
|
||||||
if (! process_object (member_filedata))
|
if (! process_object (member_filedata))
|
||||||
ret = false;
|
ret = false;
|
||||||
|
|
||||||
|
|
|
@ -310,6 +310,32 @@ proc readelf_dump_test {} {
|
||||||
# XXX FIXME: Add test of readelf -x here
|
# XXX FIXME: Add test of readelf -x here
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Tests whether readelf can read thin archives
|
||||||
|
proc readelf_thin_archive_test {} {
|
||||||
|
global AR
|
||||||
|
|
||||||
|
if ![is_remote host] {
|
||||||
|
set tempfile tmpdir/bintest.o
|
||||||
|
set templib tmpdir/bintest.thin.a
|
||||||
|
set libname tmpdir/bintest.thin.a
|
||||||
|
} else {
|
||||||
|
set tempfile [remote_download host tmpdir/bintest.o]
|
||||||
|
set templib [remote_download host tmpdir/bintest.thin.a]
|
||||||
|
set libname bintest.thin.a
|
||||||
|
}
|
||||||
|
|
||||||
|
set testname "readelf -h bintest.thin"
|
||||||
|
set got [binutils_run $AR "rcT $libname ${tempfile}"]
|
||||||
|
if ![string match "" $got] {
|
||||||
|
fail $testname
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
readelf_test -h $templib readelf.h.thin
|
||||||
|
|
||||||
|
pass $testname
|
||||||
|
}
|
||||||
|
|
||||||
if ![is_remote host] {
|
if ![is_remote host] {
|
||||||
if {[which $READELF] == 0} then {
|
if {[which $READELF] == 0} then {
|
||||||
perror "$READELF does not exist"
|
perror "$READELF does not exist"
|
||||||
|
@ -344,6 +370,8 @@ if {![binutils_assemble $srcdir/$subdir/bintest.s tmpdir/bintest.o]} then {
|
||||||
setup_xfail "mips-*-*irix*"
|
setup_xfail "mips-*-*irix*"
|
||||||
readelf_test -s $tempfile readelf.ss
|
readelf_test -s $tempfile readelf.ss
|
||||||
readelf_test -r $tempfile readelf.r
|
readelf_test -r $tempfile readelf.r
|
||||||
|
|
||||||
|
readelf_thin_archive_test
|
||||||
}
|
}
|
||||||
|
|
||||||
# Test demangling symbol names.
|
# Test demangling symbol names.
|
||||||
|
|
22
binutils/testsuite/binutils-all/readelf.h.thin
Normal file
22
binutils/testsuite/binutils-all/readelf.h.thin
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
|
||||||
|
File: .*bintest\.thin\.a.*
|
||||||
|
ELF Header:
|
||||||
|
Magic: 7f 45 4c 46 0[12] 0[12] 01 .. .. 00 00 00 00 00 00 00
|
||||||
|
Class: ELF[36][24]
|
||||||
|
Data: 2's complement,.* endian
|
||||||
|
Version: 1 \(current\)
|
||||||
|
OS/ABI: .*
|
||||||
|
ABI Version: .*
|
||||||
|
Type: REL \(Relocatable file\)
|
||||||
|
Machine: .*
|
||||||
|
Version: 0x1
|
||||||
|
Entry point address: 0x0
|
||||||
|
Start of program headers: 0 \(bytes into file\)
|
||||||
|
Start of section headers: .* \(bytes into file\)
|
||||||
|
Flags: .*
|
||||||
|
Size of this header: .* \(bytes\)
|
||||||
|
Size of program headers: 0 \(bytes\)
|
||||||
|
Number of program headers: 0
|
||||||
|
Size of section headers: .* \(bytes\)
|
||||||
|
Number of section headers: .*
|
||||||
|
Section header string table index: .*
|
Loading…
Add table
Add a link
Reference in a new issue