Re: [edk2] Getting compile failures on OS X with MdePkg/Library/BaseLib/X64/Thunk16.S

Subject: Re: [edk2] Getting compile failures on OS X with MdePkg/Library/BaseLib/X64/Thunk16.S

From: Andrew Fish <afish@apple.com>

To: edk2-devel@lists.sourceforge.net

Date: 2011-09-27 23:06:01


On Sep 27, 2011, at 2:58 PM, Jordan Justen wrote:

> On Tue, Sep 27, 2011 at 14:52, Andrew Fish  wrote:
>> Jordan,
>> 
>> Thanks! Looks like a deadlock maybe? OS X linker does not support .text section and gcc does not support .data.
> 
> Looks like there is one data section in the file currently, so
> hopefully there is a common solution.
> 

Both errors seem to be related to relocations and section types. I would assume that multiple .data sections just end up as a single bigger .data section after a link. You could try moving all the items I added to the .data section into a single .data section to see if that fixes the gcc issue? I know that works for OS X, but I was trying to make the min changes to the file.

Thanks,

Andrew

> -Jordan
> 
>> 
>> I hate to say the only thing I can think of is to add #ifdef __APPLE__ around the section changes I added. Do you have any better ideas?
>> 
>> Andrew Fish
>> 
>> 
>> 
>> 
>> 
>> On Sep 27, 2011, at 2:48 PM, Jordan Justen wrote:
>> 
>>> GCC44:
>>> .../X64/Thunk16.iii: Assembler messages:
>>> .../X64/Thunk16.iii:337: Error: invalid sections for operation on
>>> `NullSeg' and `m16Start' setting `Lm16Gdt'
>>> .../X64/Thunk16.iii:337: Error: invalid sections for operation on
>>> `_16GdtrBase' and `m16Start' setting `Lm16GdtrBase'
>>> .../X64/Thunk16.iii:337: Error: invalid sections for operation on
>>> `_EntryPoint' and `m16Start' setting `LmTransition'
>>> .../X64/Thunk16.iii:337: Error: invalid sections for operation on
>>> `_EntryPoint' and `L_SavedCr4' setting `Ltemp1'
>>> make: *** [.../X64/Thunk16.obj] Error 1
>>> 
>>> -Jordan
>>> 
>>> On Tue, Sep 27, 2011 at 13:42, Andrew Fish  wrote:
>>>> Thanks! That makes it work. Does some one have access to Linux gcc so they can test the attached patch?
>>>> 
>>>> Andrew Fish
>>>> 
>>>> 
>>>> 
>>>> 
>>>> 
>>>> 
>>>> On Sep 27, 2011, at 2:26 AM, Sun, Rui wrote:
>>>> 
>>>>> You can try:
>>>>> 
>>>>>    .byte   0xff, 0xa9                  #  jmp (_EntryPoint - L_SavedCr4)(%rcx)
>>>>>    .set    Ltemp1, _EntryPoint - L_SavedCr4
>>>>>    .long   Ltemp1
>>>>> 
>>>>> -----Original Message-----
>>>>> From: Andrew Fish [mailto:afish@apple.com]
>>>>> Sent: Tuesday, September 27, 2011 7:18 AM
>>>>> To: edk2-devel@lists.sourceforge.net
>>>>> Subject: [edk2] Getting compile failures on OS X with MdePkg/Library/BaseLib/X64/Thunk16.S
>>>>> 
>>>>> MdePkg Maintainers,
>>>>> 
>>>>> OS X does not allow relocations in the .text sections for X64, so the linker errors out in this case. I can  move all the pointer math code into the text section, but then I get a failure with the offset no longer fitting into a byte. Changing section types if the diff at the end of the mail.
>>>>> 
>>>>> Given the complexity of the code it is hard to figure out what mode the processor is in to know the correct encodings. So I was hoping some one could let me know if it is possible to do a 16-bit offset fro %rcx jmp at the location bellow?
>>>>> 
>>>>> /Users/fish/work/edk2/Build/Emulator/DEBUG_XCODE32/X64/MdePkg/Library/BaseLib/BaseLib/OUTPUT/X64/Thunk16.iii:316:Fixup of 381 too large for field width of 1
>>>>> 
>>>>>    .byte   0xff, 0x69                  #  jmp (_EntryPoint - L_SavedCr4)(%rcx)
>>>>>    .set    Ltemp1, _EntryPoint - L_SavedCr4
>>>>>    .byte   Ltemp1
>>>>> 
>>>>> 
>>>>> Andrew Fish
>>>>> 
>>>>> Index: ../MdePkg/Library/BaseLib/X64/Thunk16.S
>>>>> ===================================================================
>>>>> --- ../MdePkg/Library/BaseLib/X64/Thunk16.S   (revision 12443)
>>>>> +++ ../MdePkg/Library/BaseLib/X64/Thunk16.S   (working copy)
>>>>> @@ -150,12 +150,14 @@
>>>>>     nop
>>>>>     ret
>>>>> 
>>>>> +.data
>>>>> _EntryPoint: .long      ASM_PFX(ToUserCode) - ASM_PFX(m16Start)
>>>>>              .word      CODE16
>>>>> _16Gdtr:     .word      GDT_SIZE - 1
>>>>> _16GdtrBase: .quad      ASM_PFX(NullSeg)
>>>>> _16Idtr:     .word      0x3ff
>>>>>              .long      0
>>>>> +.text
>>>>> 
>>>>> #------------------------------------------------------------------------------
>>>>> # _ToUserCode() takes control in real mode before passing control to user code.
>>>>> @@ -198,6 +200,7 @@
>>>>>     .byte 0x66                          # make the following retf 32-bit
>>>>>     lret                                # transfer control to user code
>>>>> 
>>>>> +.data
>>>>> .set  CODE16,  ASM_PFX(_16Code) - .
>>>>> .set  DATA16,  ASM_PFX(_16Data) - .
>>>>> .set  DATA32,  ASM_PFX(_32Data) - .
>>>>> @@ -226,6 +229,7 @@
>>>>>             .byte 0
>>>>> 
>>>>> .set  GDT_SIZE, . - ASM_PFX(NullSeg)
>>>>> +.text
>>>>> 
>>>>> #------------------------------------------------------------------------------
>>>>> # IA32_REGISTER_SET *
>>>>> 
>>>>> 
>>>>> 
>>>>> 
>>>>> 
>>>> 
>>>> 
>>>> ------------------------------------------------------------------------------
>>>> All the data continuously generated in your IT infrastructure contains a
>>>> definitive record of customers, application performance, security
>>>> threats, fraudulent activity and more. Splunk takes this data and makes
>>>> sense of it. Business sense. IT sense. Common sense.
>>>> http://p.sf.net/sfu/splunk-d2dcopy1
>>>> _______________________________________________
>>>> edk2-devel mailing list
>>>> edk2-devel@lists.sourceforge.net
>>>> https://lists.sourceforge.net/lists/listinfo/edk2-devel
>>>> 
>>>> 
>>> 
>>> ------------------------------------------------------------------------------
>>> All the data continuously generated in your IT infrastructure contains a
>>> definitive record of customers, application performance, security
>>> threats, fraudulent activity and more. Splunk takes this data and makes
>>> sense of it. Business sense. IT sense. Common sense.
>>> http://p.sf.net/sfu/splunk-d2dcopy1
>>> _______________________________________________
>>> edk2-devel mailing list
>>> edk2-devel@lists.sourceforge.net
>>> https://lists.sourceforge.net/lists/listinfo/edk2-devel
>> 
>> 
>> ------------------------------------------------------------------------------
>> All the data continuously generated in your IT infrastructure contains a
>> definitive record of customers, application performance, security
>> threats, fraudulent activity and more. Splunk takes this data and makes
>> sense of it. Business sense. IT sense. Common sense.
>> http://p.sf.net/sfu/splunk-d2dcopy1
>> _______________________________________________
>> edk2-devel mailing list
>> edk2-devel@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/edk2-devel
>> 
> 
> ------------------------------------------------------------------------------
> All the data continuously generated in your IT infrastructure contains a
> definitive record of customers, application performance, security
> threats, fraudulent activity and more. Splunk takes this data and makes
> sense of it. Business sense. IT sense. Common sense.
> http://p.sf.net/sfu/splunk-d2dcopy1
> _______________________________________________
> edk2-devel mailing list
> edk2-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/edk2-devel


------------------------------------------------------------------------------
All the data continuously generated in your IT infrastructure contains a
definitive record of customers, application performance, security
threats, fraudulent activity and more. Splunk takes this data and makes
sense of it. Business sense. IT sense. Common sense.
http://p.sf.net/sfu/splunk-d2dcopy1
_______________________________________________
edk2-devel mailing list
edk2-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/edk2-devel