[PATCH] readelf: Report if no GOT section found
Jan Beulich
jbeulich@suse.com
Tue Sep 2 14:11:50 GMT 2025
On 02.09.2025 15:22, H.J. Lu wrote:
> On Mon, Sep 1, 2025 at 11:01 PM Jan Beulich <jbeulich@suse.com> wrote:
>>
>> On 01.09.2025 20:00, H.J. Lu wrote:
>>> @@ -21123,6 +21127,15 @@ process_got_section_contents (Filedata * filedata)
>>> }
>>>
>>> out:
>>> + if (! found)
>>> + {
>>> + if (filedata->is_separate)
>>> + printf (_("\nThere is no GOT section in linked file '%s'.\n"),
>>> + filedata->file_name);
>>> + else
>>> + printf (_("\nThere is no GOT section in this file.\n"));
>>> + }
>>
>> I think that no such warning should appear when --got-contents wasn't used,
>> but was implied from --all.
>>
>
> It just follows "readelf -a" for other options:
>
> [hjl@gnu-cfl-3 tmp]$ rm x.c
> [hjl@gnu-cfl-3 tmp]$ touch x.c
> [hjl@gnu-cfl-3 tmp]$ gcc -c x.c
> [hjl@gnu-cfl-3 tmp]$ readelf -a x.o
> ELF Header:
> Magic: 7f 45 4c 46 02 01 01 00 00 00 00 00 00 00 00 00
> Class: ELF64
> Data: 2's complement, little endian
> Version: 1 (current)
> OS/ABI: UNIX - System V
> ABI Version: 0
> Type: REL (Relocatable file)
> Machine: Advanced Micro Devices X86-64
> Version: 0x1
> Entry point address: 0x0
> Start of program headers: 0 (bytes into file)
> Start of section headers: 304 (bytes into file)
> Flags: 0x0
> Size of this header: 64 (bytes)
> Size of program headers: 0 (bytes)
> Number of program headers: 0
> Size of section headers: 64 (bytes)
> Number of section headers: 10
> Section header string table index: 9
>
> Section Headers:
> [Nr] Name Type Address Offset
> Size EntSize Flags Link Info Align
> [ 0] NULL 0000000000000000 00000000
> 0000000000000000 0000000000000000 0 0 0
> [ 1] .text PROGBITS 0000000000000000 00000040
> 0000000000000000 0000000000000000 AX 0 0 1
> [ 2] .data PROGBITS 0000000000000000 00000040
> 0000000000000000 0000000000000000 WA 0 0 1
> [ 3] .bss NOBITS 0000000000000000 00000040
> 0000000000000000 0000000000000000 WA 0 0 1
> [ 4] .comment PROGBITS 0000000000000000 00000040
> 000000000000002f 0000000000000001 MS 0 0 1
> [ 5] .note.GNU-stack PROGBITS 0000000000000000 0000006f
> 0000000000000000 0000000000000000 0 0 1
> [ 6] .note.gnu.pr[...] NOTE 0000000000000000 00000070
> 0000000000000030 0000000000000000 A 0 0 8
> [ 7] .symtab SYMTAB 0000000000000000 000000a0
> 0000000000000030 0000000000000018 8 2 8
> [ 8] .strtab STRTAB 0000000000000000 000000d0
> 0000000000000005 0000000000000000 0 0 1
> [ 9] .shstrtab STRTAB 0000000000000000 000000d5
> 0000000000000058 0000000000000000 0 0 1
> Key to Flags:
> W (write), A (alloc), X (execute), M (merge), S (strings), I (info),
> L (link order), O (extra OS processing required), G (group), T (TLS),
> C (compressed), x (unknown), o (OS specific), E (exclude),
> D (mbind), l (large), p (processor specific)
>
> There are no section groups in this file.
>
> There are no program headers in this file.
>
> There is no dynamic section in this file.
>
> There are no relocations in this file.
> No processor specific unwind information to decode
>
> Symbol table '.symtab' contains 2 entries:
> Num: Value Size Type Bind Vis Ndx Name
> 0: 0000000000000000 0 NOTYPE LOCAL DEFAULT UND
> 1: 0000000000000000 0 FILE LOCAL DEFAULT ABS x.c
>
> No version information found in this file.
Hmm, that's not very nice imo, but well - okay then.
Jan
More information about the Binutils
mailing list