macho and underscores on global function names
Mike Frysinger
vapier at gentoo.org
Fri Mar 16 18:42:06 PDT 2007
On Friday 16 March 2007, Mark Charney wrote:
> On mac, yasm needs to name a function "_foo" so that it can be called as
> "foo()" from C.
> global _foo
> _foo:
> ...
i'd point out that this issue has been around for quite a long time and no
other assembler has felt the need to implement to handle these details
it's really quite trivial to macro away the differences:
%ifidfn __OUTPUT_FORMAT__,macho
%define FUNC(x) _ %+ x
%else
%define FUNC(x) x
%endif
...
FUNC(foo):
...
plus, you cant focus on just the _ prefix ... gcc makes no such requirement
and it's up to each individual port to declare the actual ABI prefix:
#define USER_LABEL_PREFIX "<whatever you want>"
> (1) use ifdef's in the c program that calls it, (kinda ugly)
higher level languages should never have such ABI details encoded in them
> (2) double-label everything, with and without underscores, or
> (3) preprocess my .s file before assemlbing it to add the
> underscores as required.
the above preprocessor logic should cover all of this
-mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 827 bytes
Desc: not available
Url : http://cvs.tortall.net/pipermail/yasm-devel/attachments/20070316/09516d3e/attachment.pgp
More information about the yasm-devel
mailing list