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: Creating .note sections


Hi Ceri,

> Okay, that works, could you tell me how I would then add an equivalent
> ELF segment section? Would I have to manually craft the program headers,
> and use bfd_record_phdr?

Hang on a sec, you have to be careful with terminology here.  A
"section" is a single region in a program executable or object file.
It has attributes, a name, and usually, some contents as well.  A
"segment" is a collection of sections.  Segments also have attributes,
but no names.  Segments are used by the loader to simplify the process
of moving sections from an executable in some kind of file storage (ie
hard disk) into memory.  ELF object files do not contain segments,
only ELF executables do.  There is no such thing as a "segment
section".

Anyway, I assume that you mean "How do I add a new segment to an ELF
executable ?".  The answer is basically yes, you would have to craft
the program headers yourself.  Actually the easiest way to do this
would be to use a linker script to specify the segments explicitly when
creating the ELF executable in the first place.

But why should you want to create your own segments ?  Normally the
linker (or objcopy) will take care of this for you.

Cheers
        Nick



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