Browse Source

* Fixed setting of image base using {$IMAGEBASE X} directive.
* Cleanup of relative code.

git-svn-id: trunk@13147 -

yury 16 years ago
parent
commit
78b2618db6
4 changed files with 18 additions and 29 deletions
  1. 0 3
      compiler/globals.pas
  2. 4 2
      compiler/options.pas
  3. 3 9
      compiler/systems/t_symbian.pas
  4. 11 15
      compiler/systems/t_win.pas

+ 0 - 3
compiler/globals.pas

@@ -292,7 +292,6 @@ interface
 
 
     const
     const
        DLLsource : boolean = false;
        DLLsource : boolean = false;
-       DLLImageBase : pshortstring = nil;
 
 
        { used to set all registers used for each global function
        { used to set all registers used for each global function
          this should dramatically decrease the number of
          this should dramatically decrease the number of
@@ -1350,8 +1349,6 @@ implementation
 
 
    procedure DoneGlobals;
    procedure DoneGlobals;
      begin
      begin
-       if assigned(DLLImageBase) then
-         StringDispose(DLLImageBase);
        librarysearchpath.Free;
        librarysearchpath.Free;
        unitsearchpath.Free;
        unitsearchpath.Free;
        objectsearchpath.Free;
        objectsearchpath.Free;

+ 4 - 2
compiler/options.pas

@@ -1456,8 +1456,10 @@ begin
                           non relocatable DLL at a specific base address PM }
                           non relocatable DLL at a specific base address PM }
                         if (length(More)>j) then
                         if (length(More)>j) then
                           begin
                           begin
-                            if DLLImageBase=nil then
-                              DLLImageBase:=StringDup(Copy(More,j+1,255));
+                            val('$'+Copy(More,j+1,255),imagebase,code);
+                            if code<>0 then
+                              IllegalPara(opt);
+                            ImageBaseSetExplicity:=true;
                           end
                           end
                         else
                         else
                           begin
                           begin

+ 3 - 9
compiler/systems/t_symbian.pas

@@ -97,16 +97,10 @@ implementation
             begin
             begin
                 Concat('ENTRYNAME _E32Startup')
                 Concat('ENTRYNAME _E32Startup')
             end;
             end;
-            ibase:='';
-            if assigned(DLLImageBase) then
-              ibase:=DLLImageBase^
+            if IsSharedLibrary then
+              ibase:='10000000'
             else
             else
-            begin
-                if IsSharedLibrary then
-                  ibase:='10000000'
-                else
-                    ibase:='400000';
-            end;
+                ibase:='400000';
             Concat('IMAGEBASE $' + ibase);
             Concat('IMAGEBASE $' + ibase);
             Concat('HEADER');
             Concat('HEADER');
             Concat('EXESECTION .text');
             Concat('EXESECTION .text');

+ 11 - 15
compiler/systems/t_win.pas

@@ -931,8 +931,7 @@ implementation
 
 
     procedure TInternalLinkerWin.DefaultLinkScript;
     procedure TInternalLinkerWin.DefaultLinkScript;
       var
       var
-        s,s2,
-        ibase : TCmdStr;
+        s,s2 : TCmdStr;
         secname,
         secname,
         secnames : string;
         secnames : string;
       begin
       begin
@@ -973,23 +972,20 @@ implementation
                 else
                 else
                   Concat('ENTRYNAME _mainCRTStartup');
                   Concat('ENTRYNAME _mainCRTStartup');
               end;
               end;
-            ibase:='';
-            if assigned(DLLImageBase) then
-              ibase:=DLLImageBase^
-            else
+            if not ImageBaseSetExplicity then
               begin
               begin
                 if IsSharedLibrary then
                 if IsSharedLibrary then
-                  ibase:='10000000'
+                  imagebase:=$10000000
                 else
                 else
                   if target_info.system in system_wince then
                   if target_info.system in system_wince then
-                    ibase:='10000'
+                    imagebase:=$10000
                   else
                   else
                     if target_info.system=system_x86_64_win64 then
                     if target_info.system=system_x86_64_win64 then
-                      ibase:='100000000'
+                      imagebase:=$100000000
                     else
                     else
-                      ibase:='400000';
+                      imagebase:=$400000;
               end;
               end;
-            Concat('IMAGEBASE $' + ibase);
+            Concat('IMAGEBASE $' + hexStr(imagebase, SizeOf(imagebase)*2));
             Concat('HEADER');
             Concat('HEADER');
             Concat('EXESECTION .text');
             Concat('EXESECTION .text');
             Concat('  SYMBOL __text_start__');
             Concat('  SYMBOL __text_start__');
@@ -1353,8 +1349,8 @@ implementation
           EntryStr:='--entry=_WinMainCRTStartup'
           EntryStr:='--entry=_WinMainCRTStartup'
         else
         else
           EntryStr:='--entry=_mainCRTStartup';
           EntryStr:='--entry=_mainCRTStartup';
-        if assigned(DLLImageBase) then
-          ImageBaseStr:='--image-base=0x'+DLLImageBase^;
+        if ImageBaseSetExplicity then
+          ImageBaseStr:='--image-base=0x'+hexStr(imagebase, SizeOf(imagebase)*2);
         if (cs_link_strip in current_settings.globalswitches) then
         if (cs_link_strip in current_settings.globalswitches) then
           StripStr:='-s';
           StripStr:='-s';
         if (cs_link_map in current_settings.globalswitches) then
         if (cs_link_map in current_settings.globalswitches) then
@@ -1455,8 +1451,8 @@ implementation
           end
           end
         else
         else
           EntryStr:='--entry _DLLMainCRTStartup';
           EntryStr:='--entry _DLLMainCRTStartup';
-        if assigned(DLLImageBase) then
-          ImageBaseStr:='--image-base=0x'+DLLImageBase^;
+        if ImageBaseSetExplicity then
+          ImageBaseStr:='--image-base=0x'+hexStr(imagebase, SizeOf(imagebase)*2);
         if (cs_link_strip in current_settings.globalswitches) then
         if (cs_link_strip in current_settings.globalswitches) then
           StripStr:='-s';
           StripStr:='-s';
         if (cs_link_map in current_settings.globalswitches) then
         if (cs_link_map in current_settings.globalswitches) then