An m command is used to list symbols from object files, and M command accept an elf as an output.
This is a normal enum without any flags or without any options.
If you have pass hyphen D, it will only list the dynamic of.
Symbols.
So what is a symbol?
Symbol, as a name suggests, are symbolic references to some data or code, such as global variable
or functions.
So we symbols are used by developers so they can easily reference functions and variables throughout
a program.
CPU does not care about the names.
CPU only needs to know what address what offset it is present.
So a and symbol table contains information about the mapping of this symbol name to the symbol address
okay.
And and a single Elf file contains maximum of two symbol tables.
One is sym tab and other is dynamic.
Symbol table.
So SIM tab is a global symbol table containing all the symbols used in the current Elf file, whereas
denotes same dynamic symbol table is used during dynamic linking.
So whenever we develop a program, we will be using some symbols which are not present in our program
context that are defined in some external libraries.
So that is information is present in that dynamic symbol table.
And again the names of the strings are not present in this table.
They are present in a different section known as string table or dynamic string table.
So SIM tab has one more section which is a string table.
It uses this to list the sections names of the symbols uh, it has.
Let's see what is this all sim tab and string tab and dynamic sim table and dynamic string table.
So if I see this is a simple code again I'm using f w s and user space.
It has uh symbol table.
Along with that it also has uh a string table.
It has dynamic symbol table and it has a dynamic string.
So symbol type is different.
So this den sim string table this sim tab symbol table and string table.
And we know we have a command which I can print using.
I think we have seen Objdump.
I can print the contents of this user space and I am not.
See, let's see whether we have any string table information here.
So dynamic string.
So dynamic string is is a string, uh, section containing all the strings of the dynamic symbol table.
So these are the various strings of the dynamic symbol table.
And then you should have string table which I am not seeing here.
So it is not printing Objdump is not printing all the thing middle f, f and s userspace is printing
the sections and f is a, it is printing the sections, it is printing all the contents of all.
So here you can see dynamic sym contains six entries.
So dynamic symbol table contains six entries.
And this information is present in the dynamic string table.
And then you have symbol table which is containing 64 entries.
And this information is present in the.
String table.
So.
The string table of sym tab is string table.
It stores the null terminated strings used to reference object from different strings.
And another important point is, uh, dynamic symbol will be allocated at runtime and loaded in memory.
If you look into the red elf.
Uh, if you see Sym tab, it is not having any flags.
But whereas dynamic Sym has an alloc flag, this means it will be included during the runtime.
So if I see this code, uh, where I am not using any symbols from external, uh, libraries and I am
saying give me an m user space dot zero.
It is giving global.
It has a global symbol.
Message is a symbol.
Main is a symbol.
Three symbols.
And if I say dynamic symbols give me a dynamic symbols.
It will not be.
It will say I do not have any dynamic symbol.
I will change the code and say I will use a other function known as printf.
Hello.
Now I will compile this.
Now if I say nfd, still it is saying I do not have any dynamic symbols.
But if I say n m.
The saying you put comes extra.
So previously there was no puts right.
It added global offset table.
So two additional symbols have been added when I just add printf.
Printf is internally puts.
Now let's see an m hyphen d on user space.
Here also we don't see printf outputs.
But let's see whether it is undefined or not.
So printf or puts is very sprintf or puts.
I don't.
Okay.
We have not compiled this.
Woods is still undefined in the user space okay.
And yeah global offset table is defined.
So there is a global offset table which is defined uh here we don't see the addresses uh in the user
space, although we do if I run nmap and I don't see addresses.
But if I run without this flag I can see addresses of where this are present in the way.
What is the address of this particular symbol.
So symbol table is nothing but address map to the address mapping between address symbol name and the
actual address.
So symbol table is like a symbol.
And its address symbol is nothing but a function name or a variable name.
Anything which is, uh, used by the programmers to access a particular, uh, variable or function
throughout a program.
And that is also stored in this Elf file in some sections when we have global section, uh, symbol
table section, and once particular section for dynamic symbols.