bfd client access to PT_NOTE program segment (patch included)
fnf@toadfish.ninemoons.com
fnf@toadfish.ninemoons.com
Wed Sep 22 20:04:00 GMT 1999
I didn't get any feedback, pro or con, to my previous email, so
I assume there are no real objections to making this change.
Would someone with access to the repository please apply this
patch? It won't hurt my feelings if you see a need to tweak
it slightly for some reason. :-)
-Fred
===================================================================
1999-09-22 Fred Fish <fnf@cygnus.com>
* elf.c (bfd_section_from_phdr): Add typename variable. Use p_type
to initialize it to something meaningful. Then use it to generate
more useful segment names.
Index: elf.c
===================================================================
RCS file: /cvs/binutils/binutils/bfd/elf.c,v
retrieving revision 1.16
diff -c -p -r1.16 elf.c
*** elf.c 1999/09/04 17:07:46 1.16
--- elf.c 1999/09/23 02:57:39
*************** bfd_section_from_phdr (abfd, hdr, index)
*** 1394,1406 ****
{
asection *newsect;
char *name;
char namebuf[64];
int split;
split = ((hdr->p_memsz > 0)
&& (hdr->p_filesz > 0)
&& (hdr->p_memsz > hdr->p_filesz));
! sprintf (namebuf, split ? "segment%da" : "segment%d", index);
name = bfd_alloc (abfd, strlen (namebuf) + 1);
if (!name)
return false;
--- 1394,1418 ----
{
asection *newsect;
char *name;
+ char *typename;
char namebuf[64];
int split;
split = ((hdr->p_memsz > 0)
&& (hdr->p_filesz > 0)
&& (hdr->p_memsz > hdr->p_filesz));
! switch (hdr->p_type)
! {
! case PT_NULL: typename = "null"; break;
! case PT_LOAD: typename = "load"; break;
! case PT_DYNAMIC: typename = "dynamic"; break;
! case PT_INTERP: typename = "interp"; break;
! case PT_NOTE: typename = "note"; break;
! case PT_SHLIB: typename = "shlib"; break;
! case PT_PHDR: typename = "phdr"; break;
! default: typename = "segment"; break;
! }
! sprintf (namebuf, "%s%d%s", typename, index, split ? "a" : "");
name = bfd_alloc (abfd, strlen (namebuf) + 1);
if (!name)
return false;
*************** bfd_section_from_phdr (abfd, hdr, index)
*** 1431,1437 ****
if (split)
{
! sprintf (namebuf, "segment%db", index);
name = bfd_alloc (abfd, strlen (namebuf) + 1);
if (!name)
return false;
--- 1443,1449 ----
if (split)
{
! sprintf (namebuf, "%s%db", typename, index);
name = bfd_alloc (abfd, strlen (namebuf) + 1);
if (!name)
return false;
More information about the Binutils
mailing list