On 11/19/13 18:34, Stephen Polkowski wrote:
> Hello,
> 
>       I'm building a #GP fault handler for a shell application.  I named my
> file __gp_fault_handler.S and I added it to my inf file.  Everything compiles 
> and
> the exception handler actually works.
> 
>       However, now I want to set a global variable that is declared in a
> separate "C" file.  When I assemble my file GAS uses a R_X86_64_32S offset to 
> the
> variable.  In my other "C" files I see that the compiler uses a R_X86_64_64 
> offset
> to my variable instead.
> 
>       How can I get the GNU assembler to output a R_X86_64_64 offset in the
> EDK2 build?
> 
> 
> Thanks,
> 
> Stephen
> 
> 
> Here's a shortened version of my assembly code:
> 
>       .extern EXCEPTION_EXECUTE_HANDLER
>       .global __gp_fault_handler
> 
> __gp_fault_handler:  .code64
>       
>       # Set the GP_FAULT flag
>       movl $1, EXCEPTION_EXECUTE_HANDLER
>       
> 
> 
>       
> Here is the GNU assembler output:
> 
> Disassembly of section .text:
> 
> 0000000000000000 <__gp_fault_handler>:
> 
>    16:   c7 04 25 00 00 00 00    movl   $0x1,0x0
>    1d:   01 00 00 00
>                          19: R_X86_64_32S        EXCEPTION_EXECUTE_HANDLER

According to what I found on the web, you need to use movabs for 64-bit
displacement. Additionally, you can only use the "Areg (AL/AX/EAX/RAX)"
as source/destination register.

Hence, assuming that you want to write 4 bytes,

        .extern EXCEPTION_EXECUTE_HANDLER
        .global __gp_fault_handler

__gp_fault_handler:  .code64

        # Set the GP_FAULT flag
        movl $1, %eax
        movabs %eax, EXCEPTION_EXECUTE_HANDLER

Which assembles to

0000000000000000 <__gp_fault_handler>:
   0:   b8 01 00 00 00          mov    $0x1,%eax
   5:   a3 00 00 00 00 00 00    movabs %eax,0x0
   c:   00 00
                        6: R_X86_64_64  EXCEPTION_EXECUTE_HANDLER

Laszlo


------------------------------------------------------------------------------
Shape the Mobile Experience: Free Subscription
Software experts and developers: Be at the forefront of tech innovation.
Intel(R) Software Adrenaline delivers strategic insight and game-changing 
conversations that shape the rapidly evolving mobile landscape. Sign up now. 
http://pubads.g.doubleclick.net/gampad/clk?id=63431311&iu=/4140/ostg.clktrk
_______________________________________________
edk2-devel mailing list
edk2-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/edk2-devel

Reply via email to