Adding new section to core file
vaibhav sinha
vaibhavsinh@gmail.com
Mon Apr 6 13:30:00 GMT 2015
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
More information about the Binutils
mailing list