This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: RELASZ is set to 0 on x86_64 when developing EFI applications with gnu-efi


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.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]