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


Hi Ian,

Ah, ok, now I get it... I wasn't used to the concept of loadable segments.

The ip2k is a microcontroller and doesn't dynamically load applications. We
usually use GDB (scripted) to load the elf files and it doesn't care about
the segment table.

Unforunatly I have to link the project before I can create this file that I
need to add in (the 'upgrade.bin' file is a compressed image of a number of
the sections and then needs to be stored in the final elf for use with gdb).

I guess I could link the elf file, create the upgrade.bin, then link again
with the upgrade.bin file.

Considering the other approach (linker creating the section and then using
objcopy) - the linker doesn't seam to want to create an output section
unless there is something to put in it.

There is one other problem with dealing with the compressed image - if I
include the .text section in the compressed image and again as a normal
section then gdb wants to load it if it is marked as allocatable, and
completly looses the plot if it isn't marked as allocatable :-)

A complete solution might be to add our compressing format to the bfd code,
but somehow this doesn't sound trivial.

Nick

----- Original Message -----
From: "Ian Lance Taylor" <ian@airs.com>
To: <jafa@silicondust.com>
Sent: Thursday, May 22, 2003 4:51 PM
Subject: Re: objcopy - allocated section not in segment


*This message was transferred with a trial version of CommuniGate(tm) Pro*
"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]