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: Problems adding new section


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


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