Sfoglia il codice sorgente

* fixed library creating on x86_64-linux

git-svn-id: trunk@5828 -
florian 18 anni fa
parent
commit
db3f8575ae
3 ha cambiato i file con 42 aggiunte e 7 eliminazioni
  1. 12 2
      compiler/aasmbase.pas
  2. 28 3
      compiler/ogelf.pas
  3. 2 2
      compiler/x86/aasmcpu.pas

+ 12 - 2
compiler/aasmbase.pas

@@ -39,7 +39,14 @@ interface
     type
        TAsmsymbind=(AB_NONE,AB_EXTERNAL,AB_COMMON,AB_LOCAL,AB_GLOBAL);
 
-       TAsmsymtype=(AT_NONE,AT_FUNCTION,AT_DATA,AT_SECTION,AT_LABEL);
+       TAsmsymtype=(
+         AT_NONE,AT_FUNCTION,AT_DATA,AT_SECTION,AT_LABEL,
+         { 
+           the address of this code label is taken somewhere in the code
+           so it must be taken care of it when creating pic
+         }
+         AT_ADDR
+         );
 
        { is the label only there for getting an DataOffset (e.g. for i/o
          checks -> alt_addr) or is it a jump target (alt_jump), for debug
@@ -298,7 +305,10 @@ implementation
 
     constructor TAsmLabel.Createlocal(AList:TFPHashObjectList;nr:longint;ltyp:TAsmLabelType);
       begin
-        inherited Create(AList,target_asm.labelprefix+asmlabeltypeprefix[ltyp]+tostr(nr),AB_LOCAL,AT_LABEL);
+        if ltyp=alt_addr then
+          inherited Create(AList,target_asm.labelprefix+asmlabeltypeprefix[ltyp]+tostr(nr),AB_LOCAL,AT_ADDR)
+        else
+          inherited Create(AList,target_asm.labelprefix+asmlabeltypeprefix[ltyp]+tostr(nr),AB_LOCAL,AT_LABEL);
         labelnr:=nr;
         labeltype:=ltyp;
         is_set:=false;

+ 28 - 3
compiler/ogelf.pas

@@ -584,9 +584,31 @@ implementation
           'fpc',
           ''
         );
+        secnames_pic : array[TAsmSectiontype] of string[17] = ('',
+          '.text',
+          '.data.rel',
+          '.data.rel',
+          '.bss',
+          '.threadvar',
+          '.pdata',
+          '', { stubs }
+          '.stab',
+          '.stabstr',
+          '.idata$2','.idata$4','.idata$5','.idata$6','.idata$7','.edata',
+          '.eh_frame',
+          '.debug_frame','.debug_info','.debug_line','.debug_abbrev',
+          '.fpc',
+          '.toc'
+        );
       var
         sep : string[3];
+        secname : string;
       begin
+        if (cs_create_pic in current_settings.moduleswitches) and
+           not(target_info.system in [system_powerpc_darwin,system_i386_darwin]) then
+          secname:=secnames_pic[atype]
+        else
+          secname:=secnames[atype];
         if (use_smartlink_section and
            (aname<>'')) or (atype=sec_fpc) then
           begin
@@ -598,10 +620,10 @@ implementation
               else
                 sep:='.n_';
             end;
-            result:=secnames[atype]+sep+aname
+            result:=secname+sep+aname
           end
         else
-          result:=secnames[atype];
+          result:=secname;
       end;
 
 
@@ -752,7 +774,10 @@ implementation
                if assigned(objreloc.symbol) then
                  begin
                    if objreloc.symbol.symidx=-1 then
-                     internalerror(200603012);
+                     begin
+                       writeln(objreloc.symbol.Name);
+                       internalerror(200603012);
+                     end;
                    relsym:=objreloc.symbol.symidx;
                  end
                else

+ 2 - 2
compiler/x86/aasmcpu.pas

@@ -2249,7 +2249,7 @@ implementation
                              currsym:=objdata.symbolref(oper[opidx]^.ref^.symbol);
 {$ifdef x86_64}
                              if oper[opidx]^.ref^.refaddr=addr_pic then
-                               currabsreloc:=RELOC_PLT32
+                               currabsreloc:=RELOC_GOTPCREL
                              else
 {$endif x86_64}
                                currabsreloc:=RELOC_ABSOLUTE;
@@ -2267,7 +2267,7 @@ implementation
                          currsym:=objdata.symbolref(oper[opidx]^.ref^.symbol);
 {$ifdef x86_64}
                          if oper[opidx]^.ref^.refaddr=addr_pic then
-                           currabsreloc:=RELOC_PLT32
+                           currabsreloc:=RELOC_GOTPCREL
                          else
 {$endif x86_64}
                            currabsreloc:=RELOC_ABSOLUTE32;