Re: [AD] proposed patch for nicer asm symbols exports |
[ Thread Index |
Date Index
| More lists.liballeg.org/allegro-developers Archives
]
On Wed, Aug 04, 2004, Peter Wang wrote:
> Can you explain this a bit more deeply, or point to a document
> somewhere? I don't understand assembly at all, and I never understood
> why liballeg_unsharable existed in the first place (maybe something to
> do with calling conventions or addressing modes?). It's one of those
> mysteries that would be great to have up on the wiki.
AFAIU (I was not here at the time Allegro was designed), the
alleg_unsharable serves at least two purposes:
- provide the main() function on Unix, because the main() from the
original program has been diverted to __mangled_main_address.
- provide assembly functions that are not position independent code
(PIC). When building a Unix shared object (library), one needs to
use the -fPIC flag to create position independent code, or the
library will not be properly loaded in a shared address space. PIC
code stores a special pointer in a reserved register (EBX on x86),
which means that the compiled code cannot use EBX and will run at a
slight performance loss. Since the asm code in alleg_unsharable does
not reserve EBX, it is built as a static library instead of a
shared one.
However, on x86 library code need not be compiled with -fPIC because
the architecture allows linking non-PIC code with PIC code in the same
object. And we do not provide assembly routines on platforms that do not
allow this linking (such as Alpha, IA64, HPPA).
I would like to get rid of alleg_unsharable because its presence
means that you can only upgrade liballegro in a way that works with all
previous versions of alleg_unsharable your binaries were compiled with,
or you have to recompile all your applications, which kinda defeats the
purpose of shared libraries.
On Debian systems, I have removed the need for alleg_unsharable,
and the main() routine I posted to the END_OF_MAIN thread provides a
compatibility layer for previous or third-party allegro-using binaries.
Sam.
--
Sam Hocevar <sam@xxxxxxxxxx> <http://sam.zoy.org/>
Racism is so gay! How could you ever be racist?