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:
source share