Reputation: 10658
I am currently building a bare metal executeable, which contains some special sections containing code. However, when I do objdump -d
I only get the code for the .text
and .init.text
sections. The manpage for objdump
only says that it "only disassembles those sections which are expected to contain instructions" when using the -d
option. What sections are these, and how does objdump
tell which sections to decode? I know I can also use the -D
option to get a full decoding of all sections, but this is usually much more than I need.
Upvotes: 6
Views: 772
Reputation: 158040
objdump
internally uses libbfd
to get section information. objdump
passes a callback to bfd_map_over_sections()
which calls the callback on each section. When called, libbfd
passes a asection *
to the callback, which has a member type
. If the type contains the flags SEC_CONTENTS | SEC_CODE
it gets disassembled by objdump
when the -d
option is passed.
Getting into libbfd
is quite harder, I expect that the type detection depends on architecture, but I hope I gave you at least the right pointer. (Probably when having more time I'll dig more into this and extend the answer)..
Btw, if you need a script to filter out the sections of interest from objdump -D
you might use sed
, like this:
# ------------Place section names here ---------------vvv
objdump -D object.o | sed -rn '/Disassembly of.*\.(comment|text)/{:a;p;n;/Disassembly of/!ba}'
Upvotes: 6