This is the mail archive of the binutils@sources.redhat.com 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]

Re: DT_TEXTREL


Hans-Peter Nilsson <hans-peter.nilsson@axis.com> writes:

> That assignment causes this piece of code from
> ldlang.c:wild_doit (around 1179) to filter out SEC_READONLY
> (first == false), so elf_i386_size_dynamic_sections does not
> recognize .text as such, so does not add a DT_TEXTREL:
> 
>       /* If this is not the first input section, and the SEC_READONLY
>          flag is not currently set, then don't set it just because the
>          input section has it set.  */
> 
>       if (! first && (section->output_section->flags & SEC_READONLY) == 0)
> 	flags &= ~ SEC_READONLY;
> 
> Sorry, I haven't investigated further.  Though I don't
> understand why SEC_READONLY is filtered out above at all; that
> seems bogus to me.  Can someone explain?  Or perhaps the code
> above and neighboring code should be moved to init_os or
> something.  Ghastly confession: I worked around that bug in
> elf32-cris.c:elf_cris_size_dynamic_sections and did not follow
> up.

That code is going to add the new sections flags to the output
sections flags.  Unfortunately, SEC_READONLY is a negative flag (it
would be better to have a SEC_WRITABLE flag).  If there is only one
input section which is SEC_READONLY, we certainly do not want the
output section to be SEC_READONLY.  We only want the output section to
be SEC_READONLY if all input sections are SEC_READONLY.

So the logic here is to set the SEC_READONLY flag based on the first
input section, and clear it based on subsequent sections.  Of course,
this only works if the first section is correctly recognized as such.
Your example shows that the first section is not reliably recognized.

The function does clear SEC_READONLY in the output section if it is
clear in the input section.  But that is not enough to handle the case
of the last input section having SEC_READONLY set.

If we know that there is at least one input section, then it would
work to initialize the output sections flags to SEC_READONLY, to never
set SEC_READONLY again, and to clear SEC_READONLY if any input section
has SEC_READONLY clear.

Ian


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