[PATCH] ld: work around pr17618 testcase failure

Alan Modra amodra@gmail.com
Wed Feb 22 04:08:00 GMT 2017


On Tue, Feb 21, 2017 at 11:41:17AM +0100, Andreas Schwab wrote:
> On Feb 21 2017, "Jan Beulich" <JBeulich@suse.com> wrote:
> 
> > Some change from 2.26.1 to 2.27 causes the ld-x86-64/pr17618 test to
> > exhaust memory on a 32-bit host.
> 
> Isn't that a bug that should be fixed?

The testcase is stupidly large

$ size tmpdir/pr17618.o
   text	   data	    bss	    dec	    hex	filename
2145386275	      0	      0	2145386275	7fdfff23	tmpdir/pr17618.o

So we will have an almost 2G input buffer for this object file,
and another 2G of output buffer.  No hope to link that on a 32 bit
system..

Hmm, this code in elf64-x86-64.c:

  /* Get the section contents.  */
  if (elf_section_data (sec)->this_hdr.contents != NULL)
    contents = elf_section_data (sec)->this_hdr.contents;
  else if (!bfd_malloc_and_get_section (abfd, sec, &contents))
    {
      sec->check_relocs_failed = 1;
      return FALSE;
    }

ought to instead read section contents only when they are needed.
That would help cut down memory usage early in the linking process,
and speed up the linker a little.

-- 
Alan Modra
Australia Development Lab, IBM



More information about the Binutils mailing list