This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
Re: Problems adding new section
- From: Ian Lance Taylor <ian at airs dot com>
- To: Kumar Avijit <avijitk at iitk dot ac dot in>
- Cc: binutils at sources dot redhat dot com
- Date: 10 Sep 2003 15:01:04 -0700
- Subject: Re: Problems adding new section
- References: <3F5F6464.2010603@iitk.ac.in>
Kumar Avijit <avijitk@iitk.ac.in> writes:
> I am encountering the following problem while trying to add a
> new-section at some specified virtual address to a elf32-i386 file
> using libbfd:
> We would like the SEC_ALLOC and SEC_LOAD flags to be set in
> particular, which would mean that the section should be loaded in
> memory at runtime and the section should be read from the file. The
> problem is that for loadable sections libbfd needs to map sections to
> segments and if you try to add a new section at some vma then it gives
> an error that the section is not mapped to any segment. What all needs
> to be set for adding a section to a file with the above
> requirements. We also want to make sure that we do not overwrite any
> section or program headers of the input file.
> I have tried to use objcopy for this purpose as objcopy
> --add-section new_Section=file --set-section-flags=alloc,load obj1
> obj2.
> The above gives an error saying new_Section not in a segment.What else
> needs to be done?
If you want the section to be loaded at run time, then it must be in a
program segment. Unfortunately, objcopy does not know how to add a
new program segment to an executable.
Ian