RE: [Edk2 Dev] GCC tools flags questions

Subject: RE: [Edk2 Dev] GCC tools flags questions

From: Lu ken <>


Date: 2009-03-21 00:46:20

Hi, Andrew:
=09I am using "-dll" under UNIXGCC (mingw GCC) to generate PE32+ EFI image.=
 And use generated EFI image loaded from NT32 shell environment. I found fo=
llowing issue:
=091) Generated PE32+ EFI image contains no relocation sections. In another=
 words, EFI image use EIP relative address and need not to be relocated exp=
=09Our DxeCore will treat it as fixed launched EFI driver, so allocate memo=
ry from its image address 0x0. It should be failure.=20

=092) After work around above behavior to bypass RelocationStrip checking f=
rom PeLoader(), the EFI image is loaded but still can not be run:
=09a) The function/jump/call address is no problem because EIP relative add=
ress needs not relocation.
=09b) The pointer of global data is invalid, and addresses still based on i=
mage base address.

=09By using "-pie" in UNIXGCC(mingw GCC), data and function address need be=
 relocated explicit. In another word, ".reloc" section will be created in g=
enerate PE32+ EFI image by GCC, our DxeCore's PeLoader will fixup all addre=
ss in .reloc section. And image can be load and run in NT32's shell without=


-----Original Message-----
From: Andrew J. Fish []=20
Sent: Friday, March 20, 2009 12:55 AM
Subject: [Edk2 Dev] GCC tools flags questions

I have a question about this change?

use -pie(Position Independent for executable file) instead of "-dll". =20
A EFI image generated by UNIXGCC tool chain should be relocated when =20

PIE means generate position independent code, so that code does not =20
need relocations.  I though the purpose of -dll was to make sure =20
relocations where put into the image?

I'm not much of a GCC expert as the Apple tools construction Mach-O =20
images and link very differently than standard GCC.

Andrew Fish


To unsubscribe from this discussion, please e-mail [unsubscribeURL]


To unsubscribe from this discussion, please e-mail [unsubscribeURL]