This is the mail archive of the 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: How can I include .symtab and .strtab into .data?

How can I include content of .symtab and .strtab into .data section
(or loadable segment) using linker script?

You can't.

Have I use objcopy?

Sorry, objcopy won't help either.  .symtab and .strtab aren't treated
as normal sections by the BFD library.

It might be possible to get most of the effect by investing one day
of C programming.  To simplify thought, first apply "ld -r" so that
there is only one file involved.  Then modify that file.  First,
align its length to a multiple of 4 bytes by appending zero bytes.
Then, create the body of a new .shstrtab that is the body of the old
.shstrtab but appends two new names "_symtab" and "_strtab".  Append
that new body to the end of the file, and align the length to 0 mod 4.
Append a new block of (2+ .e_shnum) ElfXX_Shdr records, where the first
.e_shnum are copies of the existing ElfXX_Shdr, and the two new ones
are the ElfXX_Shdr for the new "_symtab" and "_strtab" sections.
Set the new .sh_flags appropriately.  Set the new .sh_offset equal
to the .sh_offset of the old ".symtab" and ".strtab" sections.
Change .e_shoff and .e_shnum to point to the new ElfXX_Shdr.  Then give
the modified file to ld to complete the load.  You'll need a new linker
script with a SECTIONS command that includes _symtab and _strtab
into the .data section (or .text section.)  The loader will
ignore the old ElfXX_Shdr and names in the old .shstrtab because
nothing points to them anymore.  Similarly, the loader will
pay no mind to the fact that the body of the .symtab and .strtab
is also pointed to by the ElfXX_Shdr{"_symtab"}.sh_offset and


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