This is the mail archive of the mailing list for the binutils project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] another discarded DWARF issue

Bob Wilson wrote:
* The comparison of the kept section size in _bfd_elf_check_kept_section does not account for changes in the section size due to linker relaxation. You may start with a bunch of identical linkonce sections, but only the one that is kept will be relaxed. If the kept section changes size, the comparison will fail (or worse, match when it shouldn't -- see below).

Replying to my own patch here.... Besides a formatting problem, I noticed that the change to elflink.c was comparing apples and oranges. It probably doesn't matter in practice, but I revised the patch to compare the sizes from the ELF section headers for both sections. I'm leaving out the Xtensa-specific part of the patch, in case that makes it easier for someone to review this piece.

I ran the testsuite with no regressions for an i686-pc-linux-gnu build, and when combined with further changes in elf32-xtensa.c, I verified that this fixes the problems for an xtensa-elf target with the testcase for bug 2342.

Is this OK?

2007-10-15 Bob Wilson <>

	* elflink.c (_bfd_elf_check_kept_section): Compare the section sizes
	from the ELF headers.
Index: elflink.c
RCS file: /cvs/src/src/bfd/elflink.c,v
retrieving revision 1.282
diff -u -p -r1.282 elflink.c
--- elflink.c	12 Oct 2007 16:25:21 -0000	1.282
+++ elflink.c	15 Oct 2007 22:21:31 -0000
@@ -8786,7 +8786,10 @@ _bfd_elf_check_kept_section (asection *s
       if ((kept->flags & SEC_GROUP) != 0)
 	kept = match_group_member (sec, kept, info);
-      if (kept != NULL && sec->size != kept->size)
+      /* The kept section may have been relaxed; compare its original size.  */
+      if (kept != NULL
+	  && (elf_section_data (sec)->this_hdr.sh_size
+	      != elf_section_data (kept)->this_hdr.sh_size))
 	kept = NULL;
       sec->kept_section = kept;

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]