public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
From: fnf@toadfish.ninemoons.com
To: binutils@sourceware.cygnus.com
Cc: fnf@cygnus.com
Subject: bfd client access to PT_NOTE program segment
Date: Mon, 20 Sep 1999 20:54:00 -0000	[thread overview]
Message-ID: <199909210359.UAA09983@toadfish.ninemoons.com> (raw)

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

             reply	other threads:[~1999-09-20 20:54 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1999-09-20 20:54 fnf [this message]
1999-09-22 20:04 ` bfd client access to PT_NOTE program segment (patch included) fnf
1999-09-24 10:09   ` Richard Henderson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=199909210359.UAA09983@toadfish.ninemoons.com \
    --to=fnf@toadfish.ninemoons.com \
    --cc=binutils@sourceware.cygnus.com \
    --cc=fnf@cygnus.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).