开发者

Making a local symbol global

Is there a way to augment a symbol scope of a function in a shared object?

I'm porting an OpenGL ES 1.x example that uses开发者_开发百科 glDrawTexiOES, which is defined in the OpenGL ES library provided for the board I'm working with, but is defined as a local symbol, so that when i compile & link the example it gives me an undefined reference.


Unfortunately that's impossible by the very nature that automatic variables are laid out in memory. (They do not reside in a stable, permanent memory location.) The only thing you could do is allocate a global variable and copy the local variable into the global at some opportune point. But in that case you might just use the global variable throughout.

There is no such thing as a particular point in time where a variable "becomes global". Global variables must be known to the program at load time and exist for the entirety of the program's life.


I do not believe that it is possible to change the disposition of a local symbol to be global without editing the library as a binary via some custom program or very low level ELF utility. But I wouldn't recommend that approach for anything that you are going to run in production, or intend to maintain.

I don't know much about GL, however, either:

  • glDrawTexiOES is local because it is considered an implementation detail of the library. In that case, as a local symbol, you must not use it, as the library authors have explicitly denied you access and can therefore alter its signature and interpretation as they see fit at any time.

  • glDrawTexiOES is supposed to be global, because it is part of the GL API, and the author of the GL library for your board has failed to inform the linker that the symbol should be exported. If that is the case, you should report a bug upstream.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜