]> Shamusworld >> Repos - rln/blobdiff - rln.c
Handle absolute BSS segment location of 'xt'
[rln] / rln.c
diff --git a/rln.c b/rln.c
index e451f4518e0916c2027d9611d994453eb1fbe10e..78ed41053bbc2a6f8b43d5a68c50f186987f2818 100644 (file)
--- a/rln.c
+++ b/rln.c
@@ -1572,11 +1572,19 @@ struct OHEADER * MakeOutputObject()
                dbase = dval;
 
                if (!bval)
-                       // BSS follows DATA
-                       bbase = dval + datasize;
+               {
+                       if (btype == -2)
+                               // BSS follows TEXT
+                               bbase = tval +  textsize;
+                       else
+                               // BSS follows DATA
+                               bbase = dval + datasize;
+               }
                else
+               {
                        // BSS is independent of DATA
                        bbase = bval;
+               }
        }
 
        // Inject segment end labels, for C compilers that expect this shite
@@ -2809,9 +2817,33 @@ int doargs(int argc, char * argv[])
                                }
                                else if ((*argv[i] == 'x' || *argv[i] == 'X'))
                                {
-                                       btype = -3;                     // BSS follows DATA
+                                       switch (argv[i][1])
+                                       {
+                                               case 'd': case 'D': case '\0':
+                                                       btype = -3;     // BSS follows DATA
+                                                       break;
+
+                                               case 't': case 'T':
+                                                       btype = -2;     // BSS follows TEXT
+                                                       if (btype == dtype)
+                                                       {
+                                                               printf("Error in bss-segment address: data-segment also follows text\n");
+                                                               return 1;
+                                                       }
+                                                       break;
+
+                                               default:
+                                                       btype = -4;     // Error
+                                                       break;
+                                       }
                                }
                                else if (GetHexValue(argv[i], &bval))
+                               {
+                                       btype = -4;
+                                       return 1;
+                               }
+
+                               if (btype == -4)
                                {
                                        printf("Error in bss-segment address: %s is not 'r', 'x[td]', or an address.", argv[i]);
                                        return 1;
@@ -3070,7 +3102,10 @@ void ShowHelp(void)
        printf("   -a <text> <data> <bss>  output absolute file (default: ABS)\n");
        printf("                           hex value: segment address\n");
        printf("                           r: relocatable segment\n");
-       printf("                           x: contiguous segment\n");
+       printf("                           x[dt]: contiguous segment\n");
+       printf("                           for contiguous bss:\n");
+       printf("                             d(default): follows data segment\n");
+       printf("                             t:          follows text segment\n");
        printf("   -b                      don't remove multiply defined local labels\n");
        printf("   -c <fname>              add contents of <fname> to command line\n");
        printf("   -d                      wait for key after link\n");