This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: [RFA] Fix binutils/14662
- From: Cary Coutant <ccoutant at google dot com>
- To: dje at google dot com
- Cc: binutils at sourceware dot org
- Date: Fri, 5 Oct 2012 13:18:40 -0700
- Subject: Re: [RFA] Fix binutils/14662
- References: <yjt2lifnbaxv.fsf@ruffy2.mtv.corp.google.com>
> @@ -920,6 +920,9 @@ _bfd_elf_make_section_from_shdr (bfd *ab
> && strncmp (&name [1], debug_sections [i].name,
> debug_sections [i].len) == 0)
> flags |= SEC_DEBUGGING;
> + /* Treat .gdb_index as a debugging section. */
> + if (strcmp (name, ".gdb_index") == 0)
> + flags |= SEC_DEBUGGING;
You're going to be doing this strcmp for every section that begins
with '\.[d-z]'. Unfortunately, the simple hash table used here has a
collision between ".gdb_index" and ".gnu_linkonce.wi". Since no pair
of entries are adjacent, you could extend the lookup to check the next
slot if the first slot is non-zero and doesn't match, and just put
.gdb_index in the 'h' slot. Something like this (untested):
diff --git a/bfd/elf.c b/bfd/elf.c
index b4043b1..a690dba 100644
--- a/bfd/elf.c
+++ b/bfd/elf.c
@@ -890,7 +890,7 @@ _bfd_elf_make_section_from_shdr (bfd *abfd,
{ NULL, 0 }, /* 'e' */
{ NULL, 0 }, /* 'f' */
{ STRING_COMMA_LEN ("gnu.linkonce.wi.") }, /* 'g' */
- { NULL, 0 }, /* 'h' */
+ { STRING_COMMA_LEN ("gdb_index") }, /* 'h' */
{ NULL, 0 }, /* 'i' */
{ NULL, 0 }, /* 'j' */
{ NULL, 0 }, /* 'k' */
@@ -908,17 +908,21 @@ _bfd_elf_make_section_from_shdr (bfd *abfd,
{ NULL, 0 }, /* 'w' */
{ NULL, 0 }, /* 'x' */
{ NULL, 0 }, /* 'y' */
- { STRING_COMMA_LEN ("zdebug") } /* 'z' */
+ { STRING_COMMA_LEN ("zdebug") }, /* 'z' */
+ { NULL, 0 } /* end */
};
if (name [0] == '.')
{
int i = name [1] - 'd';
if (i >= 0
- && i < (int) ARRAY_SIZE (debug_sections)
+ && i < (int) ARRAY_SIZE (debug_sections) - 1
&& debug_sections [i].name != NULL
- && strncmp (&name [1], debug_sections [i].name,
- debug_sections [i].len) == 0)
+ && (strncmp (&name [1], debug_sections [i].name,
+ debug_sections [i].len) == 0
+ || (debug_sections [i + 1].name != NULL
+ && (strncmp (&name [1], debug_sections [i + 1].name,
+ debug_sections [i + 1].len) == 0)))
flags |= SEC_DEBUGGING;
}
}
-cary