On Jul 25, 2014, at 4:07 AM, Varad Gautam <varadgau...@gmail.com> wrote:

> The same problem appears when I build BeagleBoardPkg:
> AutoGen.* contains proper PCDs, so does the build report. Yet, objdump
> shows PcdGet calls to return 0.
> -objdump snippets-
> ArmPlatformPrePiUnicore.lib:
> FixedPcdGet32 (PcdFdBaseAddress);
>   5e:    f04f 2080     mov.w    r0, #2147516416    ; 0x80008000
>   62:    f7ff fffe     bl    0 <PrePiMain>
> ...
>  StacksSize = PcdGet32 (PcdCPUCorePrimaryStackSize);
>   bc:    4b6e          ldr    r3, [pc, #440]    ; (278 <PrePiMain+0x278>)
>   be:    681b          ldr    r3, [r3, #0]
>   c0:    9325          str    r3, [sp, #148]    ; 0x94
> 

This looks like a GOT load. The address pc+440 is the address of the pointer to 
the global. What does pc+440 point to?

Maybe your toolchain is having an issue with GOT? 

Thanks,

Andrew Fish 

PS If you reference a global you were not compiled with, but linked with it 
becomes an indirect access.
 this is clang, but you get the idea (I used armv6 as armv7 emits movw/movt). 
The linker would patch L_global$non_lazy_ptr with a pointer to the global at 
link time.

~/work/Compiler>cat got.c


extern int global;

int test()
{
  return global;
}

~/work/Compiler>clang -arch armv6 -Os -S got.c
~/work/Compiler>cat got.S
        .section        __TEXT,__text,regular,pure_instructions
        .section        __TEXT,__textcoal_nt,coalesced,pure_instructions
        .section        __TEXT,__const_coal,coalesced
        .section        __TEXT,__picsymbolstub4,symbol_stubs,none,16
        .section        __TEXT,__StaticInit,regular,pure_instructions
        .section        __TEXT,__cstring,cstring_literals
        .syntax unified
        .section        __TEXT,__text,regular,pure_instructions
        .globl  _test
        .align  2
_test:                                  @ @test
@ BB#0:
        ldr     r0, LCPI0_0
LPC0_0:
        ldr     r0, [pc, r0]
        ldr     r0, [r0]
        bx      lr
        .align  2
@ BB#1:
        .data_region
LCPI0_0:
        .long   L_global$non_lazy_ptr-(LPC0_0+8)
        .end_data_region


        .section        __DATA,__nl_symbol_ptr,non_lazy_symbol_pointers
        .align  2
L_global$non_lazy_ptr:
        .indirect_symbol        _global
        .long   0

.subsections_via_symbols


> 
> I have tried using a different toolchain :). What else is possible? I am 
> looking into
> the BaseTools build process. Could someone please verify this for 
> BeagleBoardPkg?
> 
> 
> Thanks,
> Varad
> 

------------------------------------------------------------------------------
Want fast and easy access to all the code in your enterprise? Index and
search up to 200,000 lines of code with a free copy of Black Duck
Code Sight - the same software that powers the world's largest code
search on Ohloh, the Black Duck Open Hub! Try it now.
http://p.sf.net/sfu/bds
_______________________________________________
edk2-devel mailing list
edk2-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/edk2-devel

Reply via email to