Problems adding new section

Kumar Avijit avijitk@iitk.ac.in
Wed Sep 10 17:55:00 GMT 2003


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?

Avijit



More information about the Binutils mailing list