This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: RELASZ is set to 0 on x86_64 when developing EFI applications with gnu-efi
- From: éæ <yanmiaobest at gmail dot com>
- To: "H.J. Lu" <hjl dot tools at gmail dot com>
- Cc: Binutils <binutils at sourceware dot org>
- Date: Tue, 10 Jun 2014 11:27:18 +0800
- Subject: Re: RELASZ is set to 0 on x86_64 when developing EFI applications with gnu-efi
- Authentication-results: sourceware.org; auth=none
- References: <CAPc5xaNRCsvytiQKi52Kkimk_Qs5cFRycCy3y0hTUBNYZOb-RQ at mail dot gmail dot com> <CAMe9rOox_pqo+M6Y3NPP7fjVP5pF8woO_rA9O265gAGasxyLVg at mail dot gmail dot com> <CAPc5xaMAvYt5TKWJufvhEhUK031roZMU4=zHdLnk=MDeuoJ8Sw at mail dot gmail dot com> <CAMe9rOpgwzCyfeVW7PRVC3Bdw+0qh3RC+sYkxciq7cxfRTzuiQ at mail dot gmail dot com>
2014-06-09 23:32 GMT+08:00 H.J. Lu <hjl.tools@gmail.com>:
> On Sun, Jun 8, 2014 at 7:07 PM, éæ <yanmiaobest@gmail.com> wrote:
>> 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;
>
> You put a function pointer, which is in data section, in
> ".init.before.shell" section, which you put in text
> section in linker script:
>
> .text :
> {
> *(.text)
>
> /* XXX: added for constructors */
> init_start = .;
> KEEP(*(.init.before.memory))
> einit_before_memory = .;
>
> KEEP(*(.init.before.fs))
> einit_before_fs = .;
>
> KEEP(*(.init.before.shell))
> einit_before_shell = .;
> /* XXX: added for constructors */
>
> }
>
> Did you want to put the function xxxInit in .init.before.shell?
No, I want the function pointer to be there. But it doesn't matter
where I group those sections,
I put them into .data, still makes no difference.
And I was told RELASZ is 0 because prelink is expected to fix it up.
If this is the case, when
I remove the section attribute from source file, why RELASZ becomes non-zero?
Thanks,
Miao
>
>> 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
>
>
>
> --
> H.J.