0

I'm using objcopy on bash (ubuntu linux) and im trying to copy 2 sections from an ELF file using the folowing commend:

objcopy -j .section1 -j .section2

The problem is the objcopy is adding some padding between the sections. Is there a way (a flag?) that can stop objcopy from padding the sections?

the sections are placed one after the other in the file so there is no need for any kind of padding....

Jah
  • 1,019
  • 1
  • 11
  • 25
  • 1
    How much padding? It may be required due to section alignment needs or something - not sure what the ELF spec has to say on that... – twalberg Jun 26 '12 at 19:30
  • A lot of padding. The size of the sections is 8293 bytes and the output of the objcopy is 3192837 bytes.... – Jah Jun 26 '12 at 21:01
  • 1
    Ok, that's more than padding... Does comparing the information from `objdump -h orig_file` and `objdump -h new_file` lead to anything enlightening? I wonder if one of the sections is marked as ALLOC and !LOAD or something (so it doesn't actually take much space in the original file) but is getting expanded by `objcopy`... – twalberg Jun 26 '12 at 21:17

1 Answers1

0

Solved! The problem was that the sections was one after the other but not at the same segmant. One was in a W E segment and one was in a R W segmant. And thats why objcopy messed up.

Jah
  • 1,019
  • 1
  • 11
  • 25