binutils-gdb/binutils/testsuite/binutils-all/x86-64/pr27708.dump
Alan Modra 93df3340fd readelf: report DF_1_PIE as "Position-Independent Executable"
I finally found time to teach readelf to identify PIEs in the file
header display and program header display.  So in place of
"DYN (Shared object file)" which isn't completely true, show
"DYN (Position-Independent Executable file)".

It requires a little bit of untangling code in readelf due to
process_program_headers setting up dynamic_addr and dynamic_size,
needed to scan .dynamic for the DT_FLAGS_1 entry, and
process_program_headers itself wanting to display the file type in
some cases.  At first I modified process_program_header using a
"probe" parameter similar to get_section_headers in order to inhibit
output, but decided it was cleaner to separate out
locate_dynamic_sections.

binutils/
	* readelf.c (locate_dynamic_section, is_pie): New functions.
	(get_file_type): Replace e_type parameter with filedata.  Call
	is_pie for ET_DYN.  Update all callers.
	(process_program_headers): Use local variables dynamic_addr and
	dynamic_size, updating filedata on exit from function.  Set
	dynamic_size of 1 to indicate no dynamic section or segment.
	Update tests of dynamic_size throughout.
	* testsuite/binutils-all/x86-64/pr27708.dump: Update expected output.
ld/
	* testsuite/ld-pie/vaddr-0.d: Update expected output.
gdb/
	* testsuite/lib/gdb.exp (exec_is_pie): Match new PIE readelf output.
2021-06-15 13:24:57 +09:30

33 lines
1.8 KiB
Text

Elf file type is DYN (Position-Independent Executable file)
Entry point 0x5f0
There are 11 program headers, starting at offset 64
Program Headers:
Type Offset VirtAddr PhysAddr FileSiz MemSiz Flg Align
PHDR 0x000040 0x0000000000000040 0x0000000000000040 0x000268 0x000268 R 0x8
INTERP 0x0002a8 0x00000000000002a8 0x00000000000002a8 0x00001c 0x00001c R 0x1
[Requesting program interpreter: /lib64/ld-linux-x86-64.so.2]
LOAD 0x000000 0x0000000000000000 0x0000000000000000 0x000938 0x000938 R E 0x1000
LOAD 0x000da0 0x0000000000001da0 0x0000000000001da0 0x000278 0x000279 RW 0x1000
DYNAMIC 0x000db0 0x0000000000001db0 0x0000000000001db0 0x000210 0x000210 RW 0x8
NOTE 0x0002e8 0x00000000000002e8 0x00000000000002e8 0x000030 0x000030 R 0x8
NOTE 0x0002c4 0x00000000000002c4 0x00000000000002c4 0x000078 0x000078 R 0x4
GNU_EH_FRAME 0x0008ec 0x00000000000008ec 0x00000000000008ec 0x00004c 0x00004c R 0x4
GNU_STACK 0x000000 0x0000000000000000 0x0000000000000000 0x000000 0x000000 RW 0x10
TLS 0x000da0 0x0000000000001da0 0x0000000000001da0 0x000000 0x000009 R 0x8
GNU_RELRO 0x000da0 0x0000000000001da0 0x0000000000001da0 0x000260 0x000260 RW 0x8
Section to Segment mapping:
Segment Sections...
00
01 .interp
02 .interp .note.ABI-tag .note.gnu.property .note.gnu.build-id .dynsym .dynstr .gnu.hash .hash .gnu.version .gnu.version_r .rela.dyn .rela.plt .init .plt .text .fini .rodata .eh_frame .eh_frame_hdr
03 .fini_array .init_array .dynamic .got .got.plt .data .bss
04 .dynamic
05 .note.gnu.property
06 .note.ABI-tag .note.gnu.property .note.gnu.build-id
07 .eh_frame_hdr
08
09 .tbss
10 .fini_array .init_array .dynamic .got