Which section disables objdump by default

I am currently building bare metal, which contains some special sections containing code. However, when I do objdump -d , I only get the code for the .text and .init.text . The manpage for objdump only states that it "only disassembles the sections that should contain instructions" when using the -d . Which sections are these, and how objdump tell which sections to decode? I know that I can also use the -d to get the full decoding of all partitions, but this is usually a lot more than I need.

+6
source share
1 answer

objdump internally uses libbfd to get the section information. objdump passes the bfd_map_over_sections() callback, which calls the callback in each section. When called, libbfd passes a asection * the callback that has the type member. If the type contains SEC_CONTENTS | SEC_CODE SEC_CONTENTS | SEC_CODE , it is parsed by objdump when the -d option is passed.

Going to libbfd pretty complicated, I expect type detection to be architecture dependent, but I hope I gave you at least the right pointer. (Probably when I have more time, I will dig more into this and extend the answer).


Btw, if you need a script to filter out sections of interest to you from objdump -D , you can use sed , for example:

 # ------------Place section names here ---------------vvv objdump -D object.o | sed -rn '/Disassembly of.*\.(comment|text)/{:a;p;n;/Disassembly of/!ba}' 
+5
source

Source: https://habr.com/ru/post/984365/


All Articles