Browse Source

* detect RTOC-based accesses on AIX in inline assembly, and change the
symbol names to those of the associated TOC entries

git-svn-id: trunk@20797 -

Jonas Maebe 13 years ago
parent
commit
71106219f2
2 changed files with 27 additions and 2 deletions
  1. 14 1
      compiler/powerpc/rappcgas.pas
  2. 13 1
      compiler/powerpc64/rappcgas.pas

+ 14 - 1
compiler/powerpc/rappcgas.pas

@@ -56,7 +56,7 @@ Unit rappcgas;
       { parser }
       { parser }
       procinfo,
       procinfo,
       rabase,rautils,
       rabase,rautils,
-      cgbase,cgobj
+      cgbase,cgobj,cgppc
       ;
       ;
 
 
     procedure tppcattreader.ReadSym(oper : tppcoperand);
     procedure tppcattreader.ReadSym(oper : tppcoperand);
@@ -142,6 +142,7 @@ Unit rappcgas;
         l : aint;
         l : aint;
         relsym: string;
         relsym: string;
         asmsymtyp: tasmsymtype;
         asmsymtyp: tasmsymtype;
+        isflags: tindsymflags;
 
 
       begin
       begin
         Consume(AS_LPAREN);
         Consume(AS_LPAREN);
@@ -176,6 +177,18 @@ Unit rappcgas;
               { (reg)        }
               { (reg)        }
               if actasmtoken=AS_RPAREN then
               if actasmtoken=AS_RPAREN then
                Begin
                Begin
+                 { detect RTOC-based symbol accesses }
+                 if assigned(oper.opr.ref.symbol) and
+                    (oper.opr.ref.base=NR_RTOC) and
+                    (oper.opr.ref.offset=0) then
+                   begin
+                     { replace global symbol reference with TOC entry name
+                       for AIX }
+                     if target_info.system in systems_aix then
+                       oper.opr.ref.symbol:=
+                         tcgppcgen(cg).get_aix_toc_sym(oper.opr.ref.symbol.name,asmsym2indsymflags(oper.opr.ref.symbol));
+                     oper.opr.ref.refaddr:=addr_pic_no_got;
+                   end;
                  Consume_RParen;
                  Consume_RParen;
                  exit;
                  exit;
                end;
                end;

+ 13 - 1
compiler/powerpc64/rappcgas.pas

@@ -56,7 +56,7 @@ uses
   { parser }
   { parser }
   procinfo,
   procinfo,
   rabase, rautils,
   rabase, rautils,
-  cgbase, cgobj
+  cgbase, cgobj, cgppc
   ;
   ;
 
 
 procedure tppcattreader.ReadSym(oper: tppcoperand);
 procedure tppcattreader.ReadSym(oper: tppcoperand);
@@ -188,6 +188,18 @@ begin
         { (reg)        }
         { (reg)        }
         if actasmtoken = AS_RPAREN then
         if actasmtoken = AS_RPAREN then
         begin
         begin
+          { detect RTOC-based symbol accesses }
+          if assigned(oper.opr.ref.symbol) and
+             (oper.opr.ref.base=NR_RTOC) and
+             (oper.opr.ref.offset=0) then
+            begin
+              { replace global symbol reference with TOC entry name
+                for AIX }
+              if target_info.system in systems_aix then
+                oper.opr.ref.symbol:=
+                  tcgppcgen(cg).get_aix_toc_sym(oper.opr.ref.symbol.name,asmsym2indsymflags(oper.opr.ref.symbol));
+              oper.opr.ref.refaddr:=addr_pic_no_got;
+            end;
           Consume_RParen;
           Consume_RParen;
           exit;
           exit;
         end;
         end;