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: [gold] "entry in mergeable string section not null terminated"


Cary Coutant <ccoutant@google.com> writes:

> Certain sections in your relocatable object files contain read-only
> string data; the linker tries to optimize the size of your executable
> by merging these sections together and eliminating any duplicate
> strings. For that to work, each section marked as a mergeable string
> section (one with the flags SHF_MERGE and SHF_STRINGS set) must
> consist entirely of null-terminated strings, one after the other, so
> that the linker can find each individual string.
>
> This error message is telling you that it found a section marked with
> SHF_MERGE and SHF_STRINGS, but that the section didn't end with a
> null. If you can gzip your archive
> libApplicationComponents_AnatomicProgram-debug.a and send it to me,
> I'll take a look and see if I can spot the problem. I'm not sure if
> the gnu linker is more tolerant, or if it just wasn't trying to do the
> constant merging optimization.

The GNU linker does implement this optimization, and it is more
tolerant.  When merging a string section, it reads the section into
memory, and explicitly pads it with a null character.  The code refers
to a gcc patch

http://gcc.gnu.org/ml/gcc-patches/2006-06/msg01004.html

which fixes a case where gcc marked a section as containing mergeable
strings even though the strings were not null terminated.  This was
fixed in gcc 4.1.2, so if Peter is using an earlier version of gcc that
could conceivably be the problem here.

gold could use a similar workaround.  In fact, if we just demote the
error to a warning, I think everything would work fine.  Peter, would
you be interested in trying such a patch?  Change this line in
gold/merge.cc

	      object->error(_("entry in mergeable string section "
			      "not null terminated"));

to something like

	      gold_warning(_("%s: entry in mergeable string section "
			     "not null terminated"),
			   object->name().c_str());

Ian


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