{"id":905,"date":"2022-08-30T15:09:08","date_gmt":"2022-08-30T15:09:08","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2013\/11\/09\/gcc-wl-defsym-on-mac-osx-collection-of-common-programming-errors\/"},"modified":"2022-08-30T15:09:08","modified_gmt":"2022-08-30T15:09:08","slug":"gcc-wl-defsym-on-mac-osx-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2022\/08\/30\/gcc-wl-defsym-on-mac-osx-collection-of-common-programming-errors\/","title":{"rendered":"gcc -Wl,&#8211;defsym on Mac OSX-Collection of common programming errors"},"content":{"rendered":"<p>Under Linux I can issue a<\/p>\n<pre><code>gcc -Wl,--defsym,main=main_x ..\n<\/code><\/pre>\n<p>However in Mac OSX 10 I get an error<\/p>\n<pre><code>ld: unknown option: --defsym\n<\/code><\/pre>\n<p>Does anyone know an switch for Mac&#8217;s gcc that is similar to &#8211;defsym ?<\/p>\n<ol>\n<li>\n<p><code>-alias<\/code> is the closest equivalent I could find:<\/p>\n<pre><code>-Wl,-alias,_main,_main_x\n<\/code><\/pre>\n<p>Note that it uses &#8220;raw&#8221; symbol names, so you have to prefix everything with an underscore.<\/p>\n<\/li>\n<li>\n<p>Does OSX use the gnu linker? I don&#8217;t think it does. gcc&#8217;s man page says defsym likely only works with the gnu linker:<\/p>\n<pre><code>-Wl,--defsym,__stack_limit=0x7ffe0000 to enforce a stack limit of 128KB. Note that this may only work with the GNU linker.\n<\/code><\/pre>\n<p>I&#8217;ve also seen makefiles that show the OSX linker does not do defsym. Notice the &#8216;if DARWIN&#8217; section of that makefile.<\/p>\n<\/li>\n<\/ol>\n<p id=\"rop\"><small>Originally posted 2013-11-09 22:56:51. <\/small><\/p>","protected":false},"excerpt":{"rendered":"<p>Under Linux I can issue a gcc -Wl,&#8211;defsym,main=main_x .. However in Mac OSX 10 I get an error ld: unknown option: &#8211;defsym Does anyone know an switch for Mac&#8217;s gcc that is similar to &#8211;defsym ? -alias is the closest equivalent I could find: -Wl,-alias,_main,_main_x Note that it uses &#8220;raw&#8221; symbol names, so you have [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-905","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/905","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=905"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/905\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=905"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=905"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=905"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}