Selaa lähdekoodia

* only refer to local symbols without GOT redirection on darwin/x86_64,
because on linux/x86_64
a) the resulting code crashes when using the internal assembler
b) refuses to link when using the external assembler
(and hence I don't know whether it's safe to do on other non-darwin
platforms either) -- fixes mantis #15889

git-svn-id: trunk@14971 -

Jonas Maebe 15 vuotta sitten
vanhempi
commit
a7dca09535
1 muutettua tiedostoa jossa 11 lisäystä ja 6 poistoa
  1. 11 6
      compiler/x86/cgx86.pas

+ 11 - 6
compiler/x86/cgx86.pas

@@ -397,13 +397,16 @@ unit cgx86;
           begin
             if cs_create_pic in current_settings.moduleswitches then
               begin
+                { Local data symbols must not be accessed via the GOT on
+                  darwin/x86_64 under certain circumstances (and do not
+                  have to be in other cases); however, linux/x86_64 does
+                  require it; don't know about others, so do use GOT for
+                  safety reasons
+                }
                 if (ref.symbol.bind=AB_LOCAL) and
-                   (ref.symbol.typ=AT_DATA) then
+                   (ref.symbol.typ=AT_DATA) and
+                   (target_info.system=system_x86_64_darwin) then
                   begin
-                    { Local data symbols don't have to go via the GOT (and in
-                      case of darwin must not in some cases), but they still
-                      have to be addressed using PIC (RIP-relative).
-                    }
                     { unfortunately, RIP-based addresses don't support an index }
                     if (ref.base<>NR_NO) or
                        (ref.index<>NR_NO) then
@@ -928,7 +931,9 @@ unit cgx86;
                       end
                     else if (cs_create_pic in current_settings.moduleswitches)
 {$ifdef x86_64}
-                             and not((ref.symbol.bind=AB_LOCAL) and (ref.symbol.typ=AT_DATA))
+                             and not((ref.symbol.bind=AB_LOCAL) and
+                                     (ref.symbol.typ=AT_DATA) and
+                                     (target_info.system=system_x86_64_darwin))
 {$endif x86_64}
                             then
                       begin