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]
Other format: [Raw text]

Re: Can't set file offset of program header


Hi Guilherme,

  [Sorry for the long delay in replying to your email]
  
> The problem is that, if this session has the type PT_LOAD, the linker
> calculate the file offset and put the value into p_offset of the program
> header just fine,
[snip]
> but if the session has another type (non standard, or even PT_NOTE) the
> linker set the p_offset to zero:
[snip]
> Please, what I'm doing wrong?

Nothing(1) - the linker was not expecting to have to cope with this
sceanario, so it does not handle it properly.  Have a look at the
function assign_file_positions_for_segments() in bfd/elf.c.  At the
very start of this function it removes all sections which do not have
the LOAD attribute from the segment map which is used to calculate
file offsets.

The simplest solution to this problem is to make use of the
elf_backend_modify_segment_map() function which allows a specific
backend to adjust the segment map computed in
assign_file_positions_for_segments.  Have a go at defining this
function and see if it solves the problem.

Cheers
        Nick

(1): Well one thing - do not use 8 as the p_type value for your extra
     segment.  Low numbers are reserved for future ELF extensions.
     Use a number in the range 0x70000000 to 0x7fffffff which are for
     processor specific segment types.


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