Re: [edk2] [PATCH 0/8] NASM: Object files; Thunk16; Require for non-MSVC

Subject: Re: [edk2] [PATCH 0/8] NASM: Object files; Thunk16; Require for non-MSVC

From: Sergey Isakov <isakov-sl@bk.ru>

To: edk2-devel@lists.sourceforge.net

Date: 2014-08-29 04:12:05

Hm, looks like the value remains zero forever. And this works.

On 28 . 2014 ., at 15:48, Andrew Fish <afish@apple.com> wrote:


On Aug 28, 2014, at 4:30 AM, Sergey Isakov <isakov-sl@bk.ru> wrote:

But what can you do with absolute addressing to _NullSeg?
-------
_EntryPoint:
        DD      _ToUserCode - ASM_PFX(m16Start)
        DW      CODE16
_16Gdtr:
        DW      GDT_SIZE - 1
_16GdtrBase:
        DQ      _NullSeg


It looks like Thunk16.S patches the value.
_EntryPoint: .long      ASM_PFX(ToUserCode) - ASM_PFX(m16Start)
             .word      CODE16
_16Gdtr:     .word      GDT_SIZE - 1
_16GdtrBase: .quad      0
_16Idtr:     .word      0x3ff
             .long      0
Thanks,

Andrew Fish


-------

On 28.08.2014, at 15:16, Andrew Fish wrote:


On Aug 28, 2014, at 12:15 AM, Sergey Isakov <isakov-sl@bk.ru> wrote:



Actually I just noticed you are getting an illegal text-relocation error. This is usually caused by an absolute relocation, and clang wants it to be IP relative. Basically Xcode/clang only supports a subset of the relocations that gcc uses for X64. 
If I correctly understand you, compilation for Thunk16 is not possible in XCLANG toolset because of idea of this codes?


No, but this toolchain puts extra restrictions on how things can be coded. 

For example Thunk16.asm contains absolute addressing
    lea     r8, @RetFromRealMode
But in Thunk16.S this is converted to IP relative addressing to support clang. 
   lea     L_RetFromRealMode(%rip), %r8
Some of the .set address math in Thunk16.S is also working around addressing mode limitations, as it removes relocations from the code. 

Thanks,

Andrew Fish 
------------------------------------------------------------------------------
Slashdot TV.  
Video for Nerds.  Stuff that matters.
http://tv.slashdot.org/_______________________________________________
edk2-devel mailing list
edk2-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/edk2-devel

------------------------------------------------------------------------------
Slashdot TV.  
Video for Nerds.  Stuff that matters.
http://tv.slashdot.org/_______________________________________________
edk2-devel mailing list
edk2-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/edk2-devel

------------------------------------------------------------------------------
Slashdot TV.  
Video for Nerds.  Stuff that matters.
http://tv.slashdot.org/_______________________________________________
edk2-devel mailing list
edk2-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/edk2-devel