greydet
greydet

Reputation: 5539

Data size of a symbol

Using the vxWorks API symFind() we can get the address of a global variable knowing its name. Is there a way to know the corresponding size of a symbol?

The fact is that the searched symbol could be of any type and I need to find it at runtime. So I basically can't use the sizeof directive.

Upvotes: 3

Views: 714

Answers (1)

ruakh
ruakh

Reputation: 183290

This is a priori impossible, since when you add a symbol, you never specify its size: the symAdd function just takes a SYMTAB_ID, a name, an address, a type ID, and a group ID. Some of the predefined type IDs imply a size (or at least, imply enough information that you could examine the data at the address and infer a size), but other predefined type IDs do not; and even if they all did, the API still wouldn't have any way to know about user-defined types (since it just sees them as opaque integer identifiers).

Upvotes: 2

Related Questions