This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Adding new section to core file
- From: vaibhav sinha <vaibhavsinh at gmail dot com>
- To: binutils at sourceware dot org
- Date: Mon, 6 Apr 2015 19:00:00 +0530
- Subject: Adding new section to core file
- Authentication-results: sourceware.org; auth=none
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