1

I would like to see at one glance which variables are placed next to each other in memory. If I generate a symbol table by using objdump -t I get the symbol table, however sorted seemingly randomly.

SYMBOL TABLE:
00100584 l     F .text  00000000 deregister_tm_clones
001005a8 l     F .text  00000000 register_tm_clones
001005d4 l     F .text  00000000 __do_global_dtors_aux
0019c020 l       .bss   00000001 completed.10177
0019c00c l     O .fini_array    00000000 __do_global_dtors_aux_fini_array_entry
00100604 l     F .text  00000000 frame_dummy
0019c024 l       .bss   00000018 object.10182
0019c008 l     O .init_array    00000000 __frame_dummy_init_array_entry
00000000 l    df *ABS*  00000000 tcp_server_test.c
0019c03c l       .bss   00000004 xServerWorkTaskHandle
001006a4 l     F .text  00000098 prvServerWorkTask
0019c040 l       .bss   00000008 xMyTelnet
...

Is there a way to get it sorted by address (first column) in upcounting manner?

It would be great if there was a switch that could be added to objdump -t to get the desired output. I looked through the documentation and did not find anything like that, but maybe I overlooked something?

Another approach could be to write a python script that resorts it, but I would like to avoid that if possible.

Thanks!

Stone
  • 33
  • 6

1 Answers1

2

You can use the universal tool "sort" to sort the output of "objdump".

Please read its documentation for options. Without any option, it simply sorts on the first column.


For the no-yet-enlightened command line user...

You need to "pipe" the output of "objdump" as input into "sort" like this:

objdump -t my_module.o | sort

the busybee
  • 10,755
  • 3
  • 13
  • 30
  • Sort on first column is perfect for this application, you don't need any additional switches, except maybe for -n to tell it to sort numerical values. – Stone May 04 '22 at 12:06
  • Does this also works on windows? What's the solution in windows? – mohammadsdtmnd Jan 03 '23 at 08:38
  • @mohammadsdtmnd Why didn't you simply try it? At least Win10 on the currently used machine knows a tool of the same name. – the busybee Jan 03 '23 at 13:03
  • @thebusybee `sort(arm-none-eabi-objdump ANC_fxlms_v1.elf -t)` doesnn't work in Win10. – mohammadsdtmnd Jan 03 '23 at 13:51
  • 1
    @mohammadsdtmnd You might want to refresh your knowledge of command line usage; see my edit. -- Oh, and "_does not work_" is not a helpful statement. ;-) You might want to post an own question, if you have a serious issue. SO is not a forum. – the busybee Jan 03 '23 at 14:04