aboutsummaryrefslogtreecommitdiff
path: root/bfd/elf.c
diff options
context:
space:
mode:
authorRichard Henderson <rth@redhat.com>1999-09-24 17:06:35 +0000
committerRichard Henderson <rth@redhat.com>1999-09-24 17:06:35 +0000
commit27ac83bfcace91578a4fa06863bb8a62bc11c2cb (patch)
tree7c77e080d07718d4bad92cd14bc357080ba78226 /bfd/elf.c
parent2d35e9f64f547cb4fe7f97c69b4aca6bfad8f5f3 (diff)
downloadgdb-27ac83bfcace91578a4fa06863bb8a62bc11c2cb.zip
gdb-27ac83bfcace91578a4fa06863bb8a62bc11c2cb.tar.gz
gdb-27ac83bfcace91578a4fa06863bb8a62bc11c2cb.tar.bz2
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.
Diffstat (limited to 'bfd/elf.c')
-rw-r--r--bfd/elf.c16
1 files changed, 14 insertions, 2 deletions
diff --git a/bfd/elf.c b/bfd/elf.c
index 5bfde4e..ccfb00e 100644
--- a/bfd/elf.c
+++ b/bfd/elf.c
@@ -1394,13 +1394,25 @@ bfd_section_from_phdr (abfd, hdr, index)
{
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));
- sprintf (namebuf, split ? "segment%da" : "segment%d", index);
+ 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;
@@ -1431,7 +1443,7 @@ bfd_section_from_phdr (abfd, hdr, index)
if (split)
{
- sprintf (namebuf, "segment%db", index);
+ sprintf (namebuf, "%s%db", typename, index);
name = bfd_alloc (abfd, strlen (namebuf) + 1);
if (!name)
return false;