Fix for bug #37 (Wrong values in data symbols when linking mult. files)

Thanks to SCPCD for the patch! Also, revbump to v.1.3.6.
This commit is contained in:
Shamus Hammons 2015-09-03 07:48:15 -05:00
parent 1614b4cc59
commit 5c7a0db5a2
2 changed files with 15 additions and 15 deletions

28
rln.c
View File

@ -674,13 +674,7 @@ int RelocateSegment(struct OFILE * ofile, int flag)
// then update the COF TEXT segment offset allowing for the phrase padding
if ((flag == T_TEXT) && !ofile->o_header.absrel.reloc.tsize)
{
// TEXT segment size plus padding
pad = ((ofile->o_header.tsize + secalign) & ~secalign);
textoffset += (ofile->o_header.tsize + (pad - ofile->o_header.tsize));
if (vflag > 1)
printf("RelocateSegment(%s, TEXT) : No Relocation Data\n", ofile->o_name);
// SCPCD : we should not increment the textoffset before the end of processing the object file, else data section will point to wrong textoffset
return 0;
}
@ -689,6 +683,15 @@ int RelocateSegment(struct OFILE * ofile, int flag)
// padding
if ((flag == T_DATA) && !ofile->o_header.absrel.reloc.dsize)
{
// SCPCD : the T_DATA is the last section of the file, we can now increment the textoffset, dataoffset and bssoffset
// TEXT segment size plus padding
pad = ((ofile->o_header.tsize + secalign) & ~secalign);
textoffset += (ofile->o_header.tsize + (pad - ofile->o_header.tsize));
if (vflag > 1)
printf("RelocateSegment(%s, TEXT) : No Relocation Data\n", ofile->o_name);
// DATA segment size plus padding
pad = ((ofile->o_header.dsize + secalign) & ~secalign);
dataoffset += (ofile->o_header.dsize + (pad - ofile->o_header.dsize));
@ -783,10 +786,8 @@ int RelocateSegment(struct OFILE * ofile, int flag)
case 0x00000200: // Absolute Value
break;
case 0x00000400: // TEXT segment relocation record
if (flag == T_TEXT) // Is this a TEXT section record?
// SCPCD : the symbol point to a text segment, we should use the textoffset
newdata = tbase + textoffset + olddata;
else
newdata = tbase + dataoffset + olddata; // Nope, must be DATA section
break;
case 0x00000600: // DATA segment relocation record
@ -840,14 +841,13 @@ int RelocateSegment(struct OFILE * ofile, int flag)
}
// Update the COF segment offset allowing for the phrase padding.
if (flag == T_TEXT)
// SCPCD : we should not increment the textoffset before the end of processing the object file, else data section will point to wrong textoffset
if (flag == T_DATA)
{
// TEXT segment plus padding
pad = ((ofile->o_header.tsize + secalign) & ~secalign);
textoffset += (ofile->o_header.tsize + (pad - ofile->o_header.tsize));
}
else
{
// DATA segment plus padding
pad = ((ofile->o_header.dsize + secalign) & ~secalign);
dataoffset += (ofile->o_header.dsize + (pad - ofile->o_header.dsize));

2
rln.h
View File

@ -52,7 +52,7 @@
#define MAJOR 1 // Major version number
#define MINOR 3 // Minor version number
#define PATCH 5 // Patch release number
#define PATCH 6 // Patch release number
#ifdef WIN32
#define PLATFORM "Win32" // Release platform - Windows