This is the mail archive of the binutils@sourceware.org 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: PR binutils/3186: symbol `.debug_abbrev' required but not present


Hi,

I see code like this a lot throughout binutils codebase,
and I just waiting for a bug like this to pop the question.


H. J. Lu wrote:
The length of "gnu.linkonce.wi." is 16 not 17. I am checking it in.

H.J.
---
2006-09-10  H.J. Lu  <hongjiu.lu@intel.com>

	PR binutils/3186
	* elf.c (_bfd_elf_make_section_from_shdr): Correct length of
	"gnu.linkonce.wi.".

--- bfd/elf.c.foo	2006-09-10 16:17:24.000000000 -0700
+++ bfd/elf.c	2006-09-10 16:44:21.000000000 -0700
@@ -819,7 +819,7 @@ _bfd_elf_make_section_from_shdr (bfd *ab
 	  { "debug",		 5  },	/* 'd' */
 	  { NULL,		 0  },	/* 'e' */
 	  { NULL,		 0  },	/* 'f' */
-	  { "gnu.linkonce.wi.", 17 },	/* 'g' */
+	  { "gnu.linkonce.wi.", 16 },	/* 'g' */
 	  { NULL,		 0  },	/* 'h' */
 	  { NULL,		 0  },	/* 'i' */
 	  { NULL,		 0  },	/* 'j' */



Why not have a standard macro for this?

#define STR_STRLEN_PAIR(STR) \
	STR, (sizeof (STR) - 1)

Then these cases become either:

  	  { STR_STRLEN_PAIR("debug")  },	/* 'd' */
  	  { NULL,		 0  },	/* 'e' */
  	  { NULL,		 0  },	/* 'f' */
	  { STR_STRLEN_PAIR("gnu.linkonce.wi.") },	/* 'g' */
 	  { NULL,		 0  },	/* 'h' */
  	  { NULL,		 0  },	/* 'i' */
  	  { NULL,		 0  },	/* 'j' */

If you want to keep looking at the string for NULLness,
or ...:

  	  { STR_STRLEN_PAIR("debug") },	/* 'd' */
  	  { STR_STRLEN_PAIR("") },	/* 'd' */
  	  { STR_STRLEN_PAIR("") },	/* 'e' */
  	  { STR_STRLEN_PAIR("")  },	/* 'f' */
	  { STR_STRLEN_PAIR("gnu.linkonce.wi.") },	/* 'g' */
  	  { STR_STRLEN_PAIR("")  },	/* 'h' */
  	  { STR_STRLEN_PAIR("")  },	/* 'i' */
  	  { STR_STRLEN_PAIR("")  },	/* 'j' */

... if you just look at the len.

Just a thought, I am not suggesting to go all over
the code base to adapt to something like this, but we
could make new code use something like this.

Cheers,
Pedro Alves


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