alias of structure members

Ángel González keisial@gmail.com
Sat Feb 11 21:31:00 GMT 2012


I'm trying to define some symbols which are just alias to the struct
members of
a global/static variable.
 
See testcase below:
 
struct Foo_struct {
       int Foodata;
} Foo;
 
extern int __attribute__((alias("Foo.Foodata"))) Localfoo;
 
struct Bar_struct {
       int Bardata;
};
struct Bar_struct  Bar;
 
extern int __attribute__((alias("Bar.Bardata"))) Localbar;
 
struct Baz_struct {
       int Bazdata[4];
};
struct Baz_struct  Baz;
 
extern int __attribute__((alias("Baz.Bazdata"))) Localbaz[4];
 
int main() {}
 
This syntax works fine in gcc 3.4 but seems to have disappeared in gcc4,
where it complains that the symbol is aliased to undefined symbol.
It may be trying to find it with a mangled name, as that's what you are  
supposed to use in alias, but I didn't find it. The trick of looking at  
the symbols in the object file doesn't work in this case, as obviously  
the structure members don't get symbols. I wouldn't get surprised if not
working from another file, but I'm trying to do that from the same  
translation unit. Such thing was possible to do in earlier versions, and
being an extension, there's no "standard conformance" which could be
banning it. So I see no reason to not allow it.

How should that be done now?

Thanks



More information about the Gcc-help mailing list