0
[  4](sec  3)(fl 0x00)(ty   0)(scl   3) (nx 1) 0x00000000 .bss
[  6](sec  1)(fl 0x00)(ty   0)(scl   2) (nx 0) 0x00000000 fred

the number inside the square brackets is the number of the entry in the symbol table, the sec number is the section number, the fl value are the symbol's flag bits, the ty number is the symbol's type, the scl number is the symbol's storage class and the nx value is the number of auxilary entries associated with the symbol. The last two fields are the symbol's value and its name.

I want to know if is there a way to findout which one is a local and which one is a global symbol?

the same way as you can tell from lowercase/uppercase of flags when using nm command.

EDIT: i know about this too

The other common output format, usually seen with ELF based files, looks like this:

00000000 l    d  .bss   00000000 .bss
00000000 g       .text  00000000 fred

but when i use objdump -t on my object file this is not the output format im getting. (im using g++ -c to compile and my os is windows 10, if this matters)

thanks

[SOLVED] Dumpbin.exe Thanks for mentionin this in comment. this one seems so clear to understand.

shiyon sufa
  • 179
  • 3
  • 7

1 Answers1

2

You talk about nm, thus you talk about ELF files. Continue reading the manual:

The other common output format, usually seen with ELF based files, looks like this:

00000000 l    d  .bss   00000000 .bss
00000000 g       .text  00000000 fred

The symbol is a local (l), global (g), unique global (u), neither global nor local (a space) or both global and local (!).


Before asking a question, I suggest that you practices the command invocations and compare command outputs with examples in the manual parts that you are reading.

273K
  • 29,503
  • 10
  • 41
  • 64
  • i just used nm and objdump -t on the same .o file. are those outputs not going to point to same symbols ? – shiyon sufa Jul 12 '22 at 16:58
  • i read about this "The other common output format, usually seen with ELF based files, looks like this: 00000000 l d .bss 00000000 .bss" too but when i use that command it wont show me this format. – shiyon sufa Jul 12 '22 at 17:01
  • @shiyonsufa It is very strange. I see normal `00000000000021c0 g F __TEXT,__text _func`. – 273K Jul 12 '22 at 17:11
  • did you just compiled my code and tried objdump -t ? im using g++ -c and using windows 10 – shiyon sufa Jul 12 '22 at 17:14
  • `windows 10` - is very important and was missing information in your question. Your .o is not ELF, but is PE. – 273K Jul 12 '22 at 17:26
  • so is there anyway to tell which one is global or local ? hope there be – shiyon sufa Jul 12 '22 at 17:38
  • 1
    [Dumpbin.exe](https://learn.microsoft.com/en-us/cpp/build/reference/dumpbin-reference?view=msvc-170) perhaps? – heap underrun Jul 12 '22 at 17:40
  • thanks you @heapunderrun is there anyway to turn off line wrapping in terminals, because wrapping makes a mess of these tables – shiyon sufa Jul 12 '22 at 20:44
  • 1
    @shiyonsufa You can just redirect the Dumpbin's output into a text file, using the regular [CMD shell redirection syntax](https://ss64.com/nt/syntax-redirection.html), like this: `DUMPBIN /ALL /DISASM /RAWDATA:NONE my_app.obj > dumped_output.txt` and then open the resultant file (`dumped_output.txt`) in your favorite text editor (like Notepad++), where you can easily disable line wrapping, also search for something etc. – heap underrun Jul 12 '22 at 22:36
  • @heapunderrun wow thanks alot, you are my hero – shiyon sufa Jul 13 '22 at 14:20