* Adding new section to core file
@ 2015-04-06 13:30 vaibhav sinha
2015-04-08 3:14 ` Alan Modra
0 siblings, 1 reply; 2+ messages in thread
From: vaibhav sinha @ 2015-04-06 13:30 UTC (permalink / raw)
To: binutils
Hi
As I understand, core files are also in ELF format. I want to add a
new section to the core file. I know how to do that for an executable
using objcopy, as shown below:
$ echo 'int main() { puts ("Hello world"); }' | gcc -x c - -c -o hello.o
$ echo "this is my special data" >mydata
$ objcopy --add-section .mydata=mydata \
--set-section-flags .mydata=noload,readonly hello.o hello2.o
$ gcc hello2.o -o hello
$ ./hello
Hello world
$ objdump -sj .mydata hello
hello: file format elf32-i386
Contents of section .mydata:
0000 74686973 20697320 6d792073 70656369 this is my speci
0010 616c2064 6174610a al data.
But when I try the same for a core file, I get warnings such as
BFD: newcorefile5: warning: allocated section `load2' not in segment
BFD: newcorefile5: warning: allocated section `load4' not in segment
BFD: newcorefile5: warning: allocated section `load5' not in segment
BFD: newcorefile5: warning: allocated section `load8' not in segment
BFD: newcorefile5: warning: allocated section `load9' not in segment
BFD: newcorefile5: warning: allocated section `load10' not in segment
BFD: newcorefile5: warning: allocated section `load13' not in segment
BFD: newcorefile5: warning: allocated section `load14' not in segment
BFD: newcorefile5: warning: allocated section `load17' not in segment
BFD: newcorefile5: warning: allocated section `load20' not in segment
BFD: newcorefile5: warning: allocated section `load21' not in segment
BFD: newcorefile5: warning: allocated section `load22' not in segment
BFD: newcorefile5: warning: allocated section `load23' not in segment
BFD: newcorefile5: warning: allocated section `load24' not in segment
BFD: newcorefile5: warning: allocated section `load25' not in segment
BFD: newcorefile5: warning: allocated section `load26' not in segment
Using objdump I cant find the new section that I added.
Can someone please help me with adding a new section to core file in a
similar manner as we add it to an executable.
Regards
Vaibhav
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: Adding new section to core file
2015-04-06 13:30 Adding new section to core file vaibhav sinha
@ 2015-04-08 3:14 ` Alan Modra
0 siblings, 0 replies; 2+ messages in thread
From: Alan Modra @ 2015-04-08 3:14 UTC (permalink / raw)
To: vaibhav sinha; +Cc: binutils
On Mon, Apr 06, 2015 at 07:00:00PM +0530, vaibhav sinha wrote:
> As I understand, core files are also in ELF format. I want to add a
> new section to the core file. I know how to do that for an executable
> using objcopy, as shown below:
But, you didn't "do that for an executable". You added the extra
section to a relocatable object file. That is very different from
adding a section to an executable (or core file). Generally, you
can't successfully change executables using objcopy in ways that
require addresses to change.
--
Alan Modra
Australia Development Lab, IBM
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2015-04-08 3:14 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-04-06 13:30 Adding new section to core file vaibhav sinha
2015-04-08 3:14 ` Alan Modra
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).