gcc -Wl,–defsym on Mac OSX-Collection of common programming errors

Under Linux I can issue a

gcc -Wl,--defsym,main=main_x ..

However in Mac OSX 10 I get an error

ld: unknown option: --defsym

Does anyone know an switch for Mac’s gcc that is similar to –defsym ?

  1. -alias is the closest equivalent I could find:

    -Wl,-alias,_main,_main_x
    

    Note that it uses “raw” symbol names, so you have to prefix everything with an underscore.

  2. Does OSX use the gnu linker? I don’t think it does. gcc’s man page says defsym likely only works with the gnu linker:

    -Wl,--defsym,__stack_limit=0x7ffe0000 to enforce a stack limit of 128KB. Note that this may only work with the GNU linker.
    

    I’ve also seen makefiles that show the OSX linker does not do defsym. Notice the ‘if DARWIN’ section of that makefile.

Originally posted 2013-11-09 22:56:51.