public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* How can I include .symtab and .strtab into .data?
@ 2015-08-21  0:16 Yuri Zilber
  2015-08-21  3:47 ` Alan Modra
  0 siblings, 1 reply; 3+ messages in thread
From: Yuri Zilber @ 2015-08-21  0:16 UTC (permalink / raw)
  To: binutils

Hello,

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

Thank you,
    Yuri

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: How can I include .symtab and .strtab into .data?
  2015-08-21  0:16 How can I include .symtab and .strtab into .data? Yuri Zilber
@ 2015-08-21  3:47 ` Alan Modra
  2015-08-21 14:16   ` John Reiser
  0 siblings, 1 reply; 3+ messages in thread
From: Alan Modra @ 2015-08-21  3:47 UTC (permalink / raw)
  To: Yuri Zilber; +Cc: binutils

On Thu, Aug 20, 2015 at 05:16:44PM -0700, Yuri Zilber wrote:
> 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.

-- 
Alan Modra
Australia Development Lab, IBM

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: How can I include .symtab and .strtab into .data?
  2015-08-21  3:47 ` Alan Modra
@ 2015-08-21 14:16   ` John Reiser
  0 siblings, 0 replies; 3+ messages in thread
From: John Reiser @ 2015-08-21 14:16 UTC (permalink / raw)
  To: binutils

>> 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
ElfXX_Shdr{"_strtab"}.sh_offset.

-- 





^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2015-08-21 14:16 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-08-21  0:16 How can I include .symtab and .strtab into .data? Yuri Zilber
2015-08-21  3:47 ` Alan Modra
2015-08-21 14:16   ` John Reiser

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).