Просмотр исходного кода

* fixed internal assembler for x86-64 so that it correctly handles
relocations for addr_pic_no_got references (do not go via the GOT)
* fixed code generator so that it generates addr_pic_no_got references
also for platforms that use the internal assembler (this will break linking
of some tests that check static data > 2GB on Linux/x86-64, but they were
already broken before as well because we don't use the "huge" x86-64
execution model)
* fixed x86-64 Linux syscall code to not expect GOT-based relocations for
the system unit's errno variable (it's an implementation-only variable)

git-svn-id: trunk@16717 -

Jonas Maebe 14 лет назад
Родитель
Сommit
0da9d36116
4 измененных файлов с 37 добавлено и 6 удалено
  1. 1 0
      compiler/options.pas
  2. 6 0
      compiler/x86/aasmcpu.pas
  3. 2 6
      compiler/x86/cgx86.pas
  4. 28 0
      rtl/linux/x86_64/syscall.inc

+ 1 - 0
compiler/options.pas

@@ -2413,6 +2413,7 @@ begin
   def_system_macro('FPC_OBJFPC_EXTENDED_IF');
   def_system_macro('FPC_OBJFPC_EXTENDED_IF');
   def_system_macro('FPC_HAS_OPERATOR_ENUMERATOR');
   def_system_macro('FPC_HAS_OPERATOR_ENUMERATOR');
   def_system_macro('FPC_HAS_CONSTREF');
   def_system_macro('FPC_HAS_CONSTREF');
+  def_system_macro('FPC_STATICRIPFIXED');
 {$if defined(x86) or defined(powerpc) or defined(powerpc64)}
 {$if defined(x86) or defined(powerpc) or defined(powerpc64)}
   def_system_macro('FPC_HAS_INTERNAL_ABS_LONG');
   def_system_macro('FPC_HAS_INTERNAL_ABS_LONG');
 {$endif}
 {$endif}

+ 6 - 0
compiler/x86/aasmcpu.pas

@@ -1946,6 +1946,12 @@ implementation
                       currabsreloc:=RELOC_GOTPCREL;
                       currabsreloc:=RELOC_GOTPCREL;
                       currabsreloc32:=RELOC_GOTPCREL;
                       currabsreloc32:=RELOC_GOTPCREL;
                     end
                     end
+                  else if oper[opidx]^.ref^.refaddr=addr_pic_no_got then
+                    begin
+                      currrelreloc:=RELOC_RELATIVE;
+                      currabsreloc:=RELOC_RELATIVE;
+                      currabsreloc32:=RELOC_RELATIVE;
+                    end
                   else
                   else
 {$endif x86_64}
 {$endif x86_64}
                     begin
                     begin

+ 2 - 6
compiler/x86/cgx86.pas

@@ -408,9 +408,7 @@ unit cgx86;
                   safety reasons
                   safety reasons
                 }
                 }
                 if (ref.symbol.bind=AB_LOCAL) and
                 if (ref.symbol.bind=AB_LOCAL) and
-                   (ref.symbol.typ=AT_DATA) and
-                   ((target_info.system=system_x86_64_darwin) or
-                    (target_info.system=system_x86_64_solaris)) then
+                   (ref.symbol.typ=AT_DATA) then
                   begin
                   begin
                     { unfortunately, RIP-based addresses don't support an index }
                     { unfortunately, RIP-based addresses don't support an index }
                     if (ref.base<>NR_NO) or
                     if (ref.base<>NR_NO) or
@@ -937,9 +935,7 @@ unit cgx86;
                     else if (cs_create_pic in current_settings.moduleswitches)
                     else if (cs_create_pic in current_settings.moduleswitches)
 {$ifdef x86_64}
 {$ifdef x86_64}
                              and not((ref.symbol.bind=AB_LOCAL) and
                              and not((ref.symbol.bind=AB_LOCAL) and
-                                     (ref.symbol.typ=AT_DATA) and
-                                     ((target_info.system=system_x86_64_darwin) or 
-                                     (target_info.system=system_x86_64_solaris)))
+                                     (ref.symbol.typ=AT_DATA))
 {$endif x86_64}
 {$endif x86_64}
                             then
                             then
                       begin
                       begin

+ 28 - 0
rtl/linux/x86_64/syscall.inc

@@ -38,7 +38,11 @@ asm
 {$ifdef FPC_PIC}
 {$ifdef FPC_PIC}
   movq  fpc_threadvar_relocate_proc@GOTPCREL(%rip),%rax
   movq  fpc_threadvar_relocate_proc@GOTPCREL(%rip),%rax
   movq  (%rax),%rax
   movq  (%rax),%rax
+{$ifndef FPC_STATICRIPFIXED}
   movq  Errno@GOTPCREL(%rip),%r11
   movq  Errno@GOTPCREL(%rip),%r11
+{$else}
+  leaq  Errno(%rip),%r11
+{$endif}
 {$else FPC_PIC}
 {$else FPC_PIC}
   movq  fpc_threadvar_relocate_proc,%rax
   movq  fpc_threadvar_relocate_proc,%rax
   leaq  Errno,%r11
   leaq  Errno,%r11
@@ -78,7 +82,11 @@ asm
 {$ifdef FPC_PIC}
 {$ifdef FPC_PIC}
   movq  fpc_threadvar_relocate_proc@GOTPCREL(%rip),%rax
   movq  fpc_threadvar_relocate_proc@GOTPCREL(%rip),%rax
   movq  (%rax),%rax
   movq  (%rax),%rax
+{$ifndef FPC_STATICRIPFIXED}
   movq  Errno@GOTPCREL(%rip),%r11
   movq  Errno@GOTPCREL(%rip),%r11
+{$else}
+  leaq  Errno(%rip),%r11
+{$endif}
 {$else FPC_PIC}
 {$else FPC_PIC}
   movq  fpc_threadvar_relocate_proc,%rax
   movq  fpc_threadvar_relocate_proc,%rax
   leaq  Errno,%r11
   leaq  Errno,%r11
@@ -121,7 +129,11 @@ asm
 {$ifdef FPC_PIC}
 {$ifdef FPC_PIC}
   movq  fpc_threadvar_relocate_proc@GOTPCREL(%rip),%rax
   movq  fpc_threadvar_relocate_proc@GOTPCREL(%rip),%rax
   movq  (%rax),%rax
   movq  (%rax),%rax
+{$ifndef FPC_STATICRIPFIXED}
   movq  Errno@GOTPCREL(%rip),%r11
   movq  Errno@GOTPCREL(%rip),%r11
+{$else}
+  leaq  Errno(%rip),%r11
+{$endif}
 {$else FPC_PIC}
 {$else FPC_PIC}
   movq  fpc_threadvar_relocate_proc,%rax
   movq  fpc_threadvar_relocate_proc,%rax
   leaq  Errno,%r11
   leaq  Errno,%r11
@@ -167,7 +179,11 @@ asm
 {$ifdef FPC_PIC}
 {$ifdef FPC_PIC}
   movq  fpc_threadvar_relocate_proc@GOTPCREL(%rip),%rax
   movq  fpc_threadvar_relocate_proc@GOTPCREL(%rip),%rax
   movq  (%rax),%rax
   movq  (%rax),%rax
+{$ifndef FPC_STATICRIPFIXED}
   movq  Errno@GOTPCREL(%rip),%r11
   movq  Errno@GOTPCREL(%rip),%r11
+{$else}
+  leaq  Errno(%rip),%r11
+{$endif}
 {$else FPC_PIC}
 {$else FPC_PIC}
   movq  fpc_threadvar_relocate_proc,%rax
   movq  fpc_threadvar_relocate_proc,%rax
   leaq  Errno,%r11
   leaq  Errno,%r11
@@ -216,7 +232,11 @@ asm
 {$ifdef FPC_PIC}
 {$ifdef FPC_PIC}
   movq  fpc_threadvar_relocate_proc@GOTPCREL(%rip),%rax
   movq  fpc_threadvar_relocate_proc@GOTPCREL(%rip),%rax
   movq  (%rax),%rax
   movq  (%rax),%rax
+{$ifndef FPC_STATICRIPFIXED}
   movq  Errno@GOTPCREL(%rip),%r11
   movq  Errno@GOTPCREL(%rip),%r11
+{$else}
+  leaq  Errno(%rip),%r11
+{$endif}
 {$else FPC_PIC}
 {$else FPC_PIC}
   movq  fpc_threadvar_relocate_proc,%rax
   movq  fpc_threadvar_relocate_proc,%rax
   leaq  Errno,%r11
   leaq  Errno,%r11
@@ -268,7 +288,11 @@ asm
 {$ifdef FPC_PIC}
 {$ifdef FPC_PIC}
   movq  fpc_threadvar_relocate_proc@GOTPCREL(%rip),%rax
   movq  fpc_threadvar_relocate_proc@GOTPCREL(%rip),%rax
   movq  (%rax),%rax
   movq  (%rax),%rax
+{$ifndef FPC_STATICRIPFIXED}
   movq  Errno@GOTPCREL(%rip),%r11
   movq  Errno@GOTPCREL(%rip),%r11
+{$else}
+  leaq  Errno(%rip),%r11
+{$endif}
 {$else FPC_PIC}
 {$else FPC_PIC}
   movq  fpc_threadvar_relocate_proc,%rax
   movq  fpc_threadvar_relocate_proc,%rax
   leaq  Errno,%r11
   leaq  Errno,%r11
@@ -324,7 +348,11 @@ asm
 {$ifdef FPC_PIC}
 {$ifdef FPC_PIC}
   movq  fpc_threadvar_relocate_proc@GOTPCREL(%rip),%rax
   movq  fpc_threadvar_relocate_proc@GOTPCREL(%rip),%rax
   movq  (%rax),%rax
   movq  (%rax),%rax
+{$ifndef FPC_STATICRIPFIXED}
   movq  Errno@GOTPCREL(%rip),%r11
   movq  Errno@GOTPCREL(%rip),%r11
+{$else}
+  leaq  Errno(%rip),%r11
+{$endif}
 {$else FPC_PIC}
 {$else FPC_PIC}
   movq  fpc_threadvar_relocate_proc,%rax
   movq  fpc_threadvar_relocate_proc,%rax
   leaq  Errno,%r11
   leaq  Errno,%r11