[coreboot] GSOC USBROM linking problem

Marc Jones marcj303 at gmail.com
Wed Jun 17 19:03:32 CEST 2009

Hi Jason,

Just got this built. I have added -m32 to the cflags and --32 to AS
flags to get it building on 64bit. You might want to add that.

Just to reiterate the problem. I objdump the usb.bin and I see that
the offset to the string is not relative but absolute.

Here is main
00000110 <main>:
     110:       8d 4c 24 04             lea    0x4(%esp),%ecx
     114:       83 e4 f0                and    $0xfffffff0,%esp
     117:       ff 71 fc                pushl  -0x4(%ecx)
     11a:       55                      push   %ebp
     11b:       89 e5                   mov    %esp,%ebp
     11d:       51                      push   %ecx
     11e:       83 ec 04                sub    $0x4,%esp
     121:       e8 3c 00 00 00          call   162 <console_init>
     126:       c7 04 24 45 42 00 00    movl   $0x4245,(%esp)
<------ that is the problem line.
     12d:       e8 ae 00 00 00          call   1e0 <puts>
     132:       eb fe                   jmp    132 <main+0x22>

and data; 66, 6f, 6f is 'foo'
00004245 <.rodata.str1.1>:
    4245:       66 6f                   outsw  %ds:(%esi),(%dx)
    4247:       6f                      outsl  %ds:(%esi),(%dx)

I don't know enough about how this is supposed to work but it looks
like the linker is setting the base to 0x00

.rodata ALIGN(4) :
      *( .rodata)
    } = 0x00

and that is exactly what is in the address, 45 42 00 00.

So, I added -fPIC to the CFLAGS and the code changes to this:

     132:       8d 83 cd fa ff ff       lea    -0x533(%ebx),%eax
     138:       89 04 24                mov    %eax,(%esp)
     13b:       e8 b0 00 00 00          call   1f0 <puts>

which seems better since it is building a relative offset but I have
no idea if it is correct.

It seems like there are a few things that need understanding.
1. How to make the code relocatable.
2. Is libpayload being built so that it can be used relocatable.



More information about the coreboot mailing list