RELASZ is set to 0 on x86_64 when developing EFI applications with gnu-efi
阎淼
yanmiaobest@gmail.com
Mon Jun 9 02:08:00 GMT 2014
Forgot to cc the list.
2014-06-06 23:08 GMT+08:00 H.J. Lu <hjl.tools@gmail.com>:
> On Fri, Jun 6, 2014 at 12:21 AM, 阎淼 <yanmiaobest@gmail.com> wrote:
>> Hi Experts,
>>
>> I am developing EFI applications using gnu-efi library and I
>> need to use some of the existing code base which groups initialization
>> functions together in a special section.
>>
>> The gnu-efi library uses the symbol _DYNAMIC to locate the
>> relocation section and does fixups before calling main. Without the
>> special section for init functions, there is only a '.rela' section
>> pointed by _DYMAMIC and everything works fine. But after I modified
>> the default linker script, the produced ELF image contains 2
>> relocation sections:
>> --------------------------------------------------------------------------------------------------------------
>> Relocation section '.rela.dyn' at offset 0x23850 contains 1 entries:
>> Offset Info Type Sym. Value Sym. Name + Addend
>> 000000027de0 000000000008 R_X86_64_RELATIVE 000000000000b7d0
>>
>
> What change you made causes rela.dyn section?
In one of the source file, I have:
void xxxInit(void)
{
....
}
static void * __func_xxxInit
__attribute__((section(".init.
before.shell"))) = (void *)xxxInit;
And in linker script I added this:
KEEP(*(.init.before.shell))
einit_before_shell = .;
The relocation entry is for the function pointer. If I remove the
"__attribute__((section(...)))" part, then
the problem disappears.
Thanks,
Miao
More information about the Binutils
mailing list