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: objcopy - allocated section not in segment


"Jafa" <jafa@silicondust.com> writes:

> I am getting the warning "warning: allocated section `.filemedia' not in
> segment" when I run the following command to add a binary image into a new
> section in an elf file:
> 
> ip2k-elf-objcopy build/bin/ip2kvm_webserver_i.elf ip2kvm_webserver.elf \
>         --add-section .filemedia=build/bin/upgrade.bin \
>         --change-section-lma .filemedia=0x03000000 \
>         --change-section-vma .filemedia=0x03000000 \
>         --set-section-flags .filemedia=contents,alloc,data,load
> 
> Looking at the BFD code the new section isn't in a segment (unlike every
> existing section) and the warning is generated because it is marked as
> allocatable. The generated elf file is correct but we are getting hundreds
> of these warnings in our nightly builds so it is starting to get annoying
> :-)

I don't see how the generated ELF file could be correct, unless you
are using a special definition of correct.  An ELF loader normally
looks at the segment table, not the section table.  Any section which
is not listed in the segment table will not get loaded.  That is why
you get the warning: because you are doing something which will not
work.

Of course, it is possible that your ELF loader uses the section table,
so it is working for you.  But it won't work for people running
ordinary Unix systems.

If it really doesn't matter for you that the section is not in a
segment, then the easy approach is certainly to just ignore the error.
Just run stderr through grep -v or something.

If you want to get the section into a segment, then you need to have
the linker create the segment for you.  I see that you are using a
particular LMA and VMA, so you will probably need to use a different
linker script which uses PHDRS.  Once you've done that, it would
probably be simpler to link the file in directly, using -b binary or
TARGET(binary) in the linker script.

Ian


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