[LinuxBIOS] support PIC and prototypes

ron minnich rminnich at gmail.com
Thu Aug 30 01:16:12 CEST 2007


On 8/29/07, Peter Stuge <peter at stuge.se> wrote:

> Did you rule out the possibility of having the functions in stage0
> that need to be called from initram in a separate file, making them
> all PIC and calling them from CAR, PIC and stage2+ alike?
>
> Would that require the pointer trick for each function in all the
> files where they're called? :\

yes. You CALLER would still need to use the pointer trick.


> > Another name?
>
> Can't come up with anything good right now.

I'm counting on you :-)


> > stage0 is not pic. If we make it pic, it ballons.
>
> Sorry, balloons? You mean it grows huge or just blows up == doesn't work?
>

grow from 4k to very large.

>
> > When gcc generates PIC code, it still generates relative calls.
>
> Isn't that (part of) the definition of PIC?

Sort of. I need relative for initram, but I need abs calls to the
stage0 code. How do I get this?

example:
[rminnich at xcpu tmp]$ cat a.s
        .file   "a.c"
        .text
.globl a
        .type   a, @function
a:
        pushl   %ebp
        movl    %esp, %ebp
        pushl   %ebx
        subl    $4, %esp
        call    __i686.get_pc_thunk.bx
        addl    $_GLOBAL_OFFSET_TABLE_, %ebx
        call    b at PLT
        addl    $4, %esp
        popl    %ebx
        popl    %ebp
        ret
        .size   a, .-a
        .ident  "GCC: (GNU) 4.1.2 20070502 (
Red Hat 4.1.2-12)"
        .section        .text.__i686.get_pc_
thunk.bx,"axG", at progbits,__i686.get_pc_thunk
.bx,comdat
.globl __i686.get_pc_thunk.bx
        .hidden __i686.get_pc_thunk.bx
        .type   __i686.get_pc_thunk.bx, @fun
ction
__i686.get_pc_thunk.bx:
        movl    (%esp), %ebx
        ret
        .section        .note.GNU-stack,"",@
progbits
[rminnich at xcpu tmp]$ cat a.c
a(){
        b();
}
[rminnich at xcpu tmp]$

note the call to b. It ends up being relative jmp. We need it to be
abs when calling stage0 ...

ron




More information about the coreboot mailing list