This is the mail archive of the
binutils@sourceware.cygnus.com
mailing list for the binutils project.
bfd client access to PT_NOTE program segment
- To: binutils at sourceware dot cygnus dot com
- Subject: bfd client access to PT_NOTE program segment
- From: fnf at toadfish dot ninemoons dot com
- Date: Mon, 20 Sep 1999 20:59:18 -0700 (MST)
- Cc: fnf at cygnus dot com
I've been looking for an easy way for a bfd client such as gdb to
identify which program segment in an ELF format core file is the
PT_NOTE section.
One somewhat obvious way is to change the synthetic segment names that
BFD generates to something more meaningful than "segmentN" and then
select the BFD section based on the name. The following patch to
elf.c (non context, for discussion purposes only) seems to do the job:
1403c1406,1417
< sprintf (namebuf, split ? "segment%da" : "segment%d", index);
---
> switch (hdr->p_type)
> {
> case PT_NULL: s = "null"; break;
> case PT_LOAD: s = "load"; break;
> case PT_DYNAMIC: s = "dynamic"; break;
> case PT_INTERP: s = "interp"; break;
> case PT_NOTE: s = "note"; break;
> case PT_SHLIB: s = "shlib"; break;
> case PT_PHDR: s = "phdr"; break;
> default: s = "segment"; break;
> }
> sprintf (namebuf, "%s%d%s", s, index, split ? "a" : "");
1434c1448
< sprintf (namebuf, "segment%db", index);
---
> sprintf (namebuf, "%s%d%b", s, index);
Then objdump produces (abbreviated) something like:
0 note0 000004fc 00000000 00000000 00000174 2**0
1 .reg/2632 00000044 00000000 00000000 000001cc 2**2
2 .reg 00000044 00000000 00000000 000001cc 2**2
3 load1 00000000 08048000 00000000 00001000 2**0
4 load2 00001000 08049000 00000000 00001000 2**0
5 load3 00000000 40000000 00000000 00002000 2**0
6 load4 00001000 40012000 00000000 00002000 2**0
7 load5 00001000 40013000 00000000 00003000 2**0
8 load6 00000000 4001a000 00000000 00004000 2**0
9 load7 00005000 40100000 00000000 00004000 2**0
10 load8 00003000 40105000 00000000 00009000 2**0
11 load9 00002000 bfffe000 00000000 0000c000 2**0
Comments about the idea of trying to generate more meaningful
BFD section names? Of using them in a BFD client? Any better
suggestions for identifying the PT_NOTE segment?
-Fred