This is the mail archive of the binutils@sourceware.cygnus.com 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]

powerpc-eabi linker crash w/linked binary data


We embed binary data (fpga images, i/o firmware, etc.) in our images
with the '-b binary' switches.  Our code references the data through
the _binary_<filename>_{start,end,size} symbols the linker creates.

This has worked fine until last week, when I began receiving reports
of linker crashes.  The linker is still the one I built from the CVS
repository back in mid-November.

When investigating the problem, I found that the linker was crashing
in elf_gc_common_finalize_got_offsets() at the line:

                if (local_got[j] > 0)

and local_got was a wild pointer.


The function iterates over all the input bfds, and local_got is
computed with elf_local_got_refcounts(i):

        ...
        /* Do the local .got entries first.  */
        for (i = info->input_bfds; i; i = i->link_next)
          {
            bfd_signed_vma *local_got = elf_local_got_refcounts (i);
            ...

elf_local_got_refcounts() is a macro which expands to elf_tdata(bfd)->
local_got.refcounts.  However, for binary data files being linked, the 
bfd tdata field points to an asection, not a struct elf_obj_tdata.  
This results in a bogus value being used, which can result in a crash.

What's the right approach to fix this problem.  Should this loop skip
non ELF input BFDs?

        --jtc

-- 
J.T. Conklin
RedBack Networks

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