Nelson Tatius
Nelson Tatius

Reputation: 8043

What is the goal to contains the information about static variables in the symbols table?

I'm trying to understand .symtab setcion type for the relocatable object files. And I know, that it contains information about static variables. But why?

All we need to do for linking relocatable object files with some other is relocate adresess of this static variable (And some others, of course, but it's don't matter for static variables). So all that we need to have -- is relocation table that stored in .rel.data and contains all information to relocate static variable, isn't it?

Upvotes: 2

Views: 222

Answers (2)

user195488
user195488

Reputation:

Not sure on your compiler, but for the IBM AIX Compiler, the default is to not add static variables to the symbol table.

However, for debugging it is quite useful for say, gdb, to know what the static variables contain and the related symbols so it would make sense for them to appear there.

Upvotes: 1

jeb
jeb

Reputation: 82192

But for debugging it can be quite useful to know where the variables are.

Upvotes: 2

Related Questions