summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorH.J. Lu <hjl.tools@gmail.com>2005-05-11 02:15:46 +0000
committerH.J. Lu <hjl.tools@gmail.com>2005-05-11 02:15:46 +0000
commit3d2b39cfded1df61fe5217e7d091a80f933e234d (patch)
treeb5172c2f85a4fc780aec6a4b5b8f05e5db2660e1
parent75919f948cc0c27405b7d50342b974ac537421d8 (diff)
2005-05-10 H.J. Lu <hongjiu.lu@intel.com>
* elf.c (_bfd_elf_make_section_from_shdr): Only check debug section if SEC_ALLOC isn't set.
-rw-r--r--bfd/ChangeLog5
-rw-r--r--bfd/elf.c56
2 files changed, 43 insertions, 18 deletions
diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index a696af5b99..a136d2f960 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,3 +1,8 @@
+2005-05-10 H.J. Lu <hongjiu.lu@intel.com>
+
+ * elf.c (_bfd_elf_make_section_from_shdr): Only check debug
+ section if SEC_ALLOC isn't set.
+
2005-05-09 Kelley Cook <kcook@gcc.gnu.org>
* configure.in: Replace AC_COMPILE_CHECK_SIZEOF with AC_CHECK_SIZEOF.
diff --git a/bfd/elf.c b/bfd/elf.c
index 5eac34fe88..8e087e32dc 100644
--- a/bfd/elf.c
+++ b/bfd/elf.c
@@ -750,25 +750,45 @@ _bfd_elf_make_section_from_shdr (bfd *abfd,
if ((hdr->sh_flags & SHF_TLS) != 0)
flags |= SEC_THREAD_LOCAL;
- /* The debugging sections appear to be recognized only by name, not
- any sort of flag. */
- {
- static const char *debug_sec_names [] =
+ if ((flags & SEC_ALLOC) == 0)
{
- ".debug",
- ".gnu.linkonce.wi.",
- ".line",
- ".stab"
- };
- int i;
-
- for (i = ARRAY_SIZE (debug_sec_names); i--;)
- if (strncmp (name, debug_sec_names[i], strlen (debug_sec_names[i])) == 0)
- break;
-
- if (i >= 0)
- flags |= SEC_DEBUGGING;
- }
+ /* The debugging sections appear to be recognized only by name,
+ not any sort of flag. Their SEC_ALLOC bits are cleared. */
+ static const struct
+ {
+ const char *name;
+ int len;
+ } debug_sections [] =
+ {
+ { "debug", 5 }, /* 'd' */
+ { NULL, 0 }, /* 'e' */
+ { NULL, 0 }, /* 'f' */
+ { "gnu.linkonce.wi.", 17 }, /* 'g' */
+ { NULL, 0 }, /* 'h' */
+ { NULL, 0 }, /* 'i' */
+ { NULL, 0 }, /* 'j' */
+ { NULL, 0 }, /* 'k' */
+ { "line", 4 }, /* 'l' */
+ { NULL, 0 }, /* 'm' */
+ { NULL, 0 }, /* 'n' */
+ { NULL, 0 }, /* 'o' */
+ { NULL, 0 }, /* 'p' */
+ { NULL, 0 }, /* 'q' */
+ { NULL, 0 }, /* 'r' */
+ { "stab", 4 } /* 's' */
+ };
+
+ if (name [0] == '.')
+ {
+ int i = name [1] - 'd';
+ if (i >= 0
+ && i < (int) ARRAY_SIZE (debug_sections)
+ && debug_sections [i].name != NULL
+ && strncmp (&name [1], debug_sections [i].name,
+ debug_sections [i].len) == 0)
+ flags |= SEC_DEBUGGING;
+ }
+ }
/* As a GNU extension, if the name begins with .gnu.linkonce, we
only link a single copy of the section. This is used to support