[SeaBIOS] parseObjDump fails when a relocation record points to a section

Kevin O'Connor kevin at koconnor.net
Tue Dec 21 04:13:20 CET 2010


On Mon, Dec 20, 2010 at 08:28:54PM +0100, Olivier Galibert wrote:
> On Sun, Dec 19, 2010 at 05:53:44PM -0500, Kevin O'Connor wrote:
> > On Sun, Dec 19, 2010 at 07:25:42PM +0100, Olivier Galibert wrote:
> > > Current git fails to compile for me with:
> > [...]
> > > The interesting parts of the associated objdump are:
> > > 
> > > Sections:
> > > Idx Name          Size      VMA       LMA       File off  Algn
> > > [...]
> > > 110 .rodata.__func__.2140 0000000a  00000000  00000000  000304fc  2**2
> > >                   CONTENTS, ALLOC, LOAD, READONLY, DATA
> > > [...]
> > > SYMBOL TABLE:
> > > [...]
> > > 00000000 l     O .rodata.__func__.2140  0000000a __func__.2140
> > > [...]
> > > 00000000 l    d  .rodata.__func__.2140  00000000 
> > > [...]
> > > RELOCATION RECORDS FOR [.debug_info]:
> > > OFFSET   TYPE              VALUE 
> > > [...]
> > > 0001419f R_386_32          .rodata.__func__.2140
> > 
> > That's odd.  It shouldn't even have tried to parse the debug
> > sections.  Can you email me a tar file of the build after running
> > "make clean; make"?
> 
> I checked further, it's not crashing on the debug section but on a
> following one:
> RELOCATION RECORDS FOR [.text.handle_02]:
> OFFSET   TYPE              VALUE 
> 00000002 R_386_32          .rodata.__func__.2140

Yeah - more binutils oddities.  Does the patch below help?  What
distro did you find this binutils on?

-Kevin


--- a/tools/layoutrom.py
+++ b/tools/layoutrom.py
@@ -532,7 +532,16 @@ def parseObjDump(file, fileid):
                 reloc.offset = int(off, 16)
                 reloc.type = type
                 reloc.symbolname = symbolname
-                reloc.symbol = symbols[symbolname]
+                reloc.symbol = symbols.get(symbolname)
+                if reloc.symbol is None:
+                    # Some binutils give section name instead of a
+                    # symbol - create a dummy symbol.
+                    reloc.symbol = symbol = Symbol()
+                    symbol.size = 0
+                    symbol.offset = 0
+                    symbol.name = symbolname
+                    symbol.section = sectionmap.get(symbolname)
+                    symbols[symbolname] = symbol
                 relocsection.relocs.append(reloc)
             except ValueError:
                 pass



More information about the SeaBIOS mailing list