Changed __edata to size end of initialized data and __end to end of bss area and...
authorRobert Pengelly <robertapengelly@hotmail.com>
Sat, 14 Dec 2024 00:54:11 +0000 (00:54 +0000)
committerRobert Pengelly <robertapengelly@hotmail.com>
Sat, 14 Dec 2024 00:54:11 +0000 (00:54 +0000)
link.c

diff --git a/link.c b/link.c
index d65c2f6731b6b84774e1c667d81a19a8bb8c5b99..01cc15932e7dc9e3c7464e1842e5ddfc5c5a4081 100644 (file)
--- a/link.c
+++ b/link.c
@@ -603,34 +603,50 @@ void link (void) {
     
     value = 0;
     
-    if ((symbol = symbol_find ("__edata")) && symbol_is_undefined (symbol)) {
+    if ((symbol = symbol_find ("__etext")) && symbol_is_undefined (symbol)) {
     
         if ((section = section_find (".text"))) {
-            value += align_section_if_needed (section->total_size);
+            value = align_section_if_needed (section->total_size);
         }
         
         of = object_file_make (FAKE_LD_FILENAME, 1);
         
         symbol = of->symbol_arr;
-        symbol->name = xstrdup ("__edata");
+        symbol->name = xstrdup ("__etext");
         
         symbol->section_number = ABSOLUTE_SECTION_NUMBER;
-        symbol->value = value / 16;
+        symbol->value = value;
         
         symbol_record_external_symbol (symbol);
     
     }
     
-    value %= 16;
+    value = 0;
     
-    if ((symbol = symbol_find ("__end")) && symbol_is_undefined (symbol)) {
+    if ((symbol = symbol_find ("__edata")) && symbol_is_undefined (symbol)) {
     
         if ((section = section_find (".data"))) {
-            value += align_section_if_needed (section->total_size);
+            value = align_section_if_needed (section->total_size);
         }
         
+        of = object_file_make (FAKE_LD_FILENAME, 1);
+        
+        symbol = of->symbol_arr;
+        symbol->name = xstrdup ("__edata");
+        
+        symbol->section_number = ABSOLUTE_SECTION_NUMBER;
+        symbol->value = value;
+        
+        symbol_record_external_symbol (symbol);
+    
+    }
+    
+    value = 0;
+    
+    if ((symbol = symbol_find ("__end")) && symbol_is_undefined (symbol)) {
+    
         if ((section = section_find (".bss"))) {
-            value += align_section_if_needed (section->total_size);
+            value = align_section_if_needed (section->total_size);
         }
         
         of = object_file_make (FAKE_LD_FILENAME, 1);
@@ -639,7 +655,7 @@ void link (void) {
         symbol->name = xstrdup ("__end");
         
         symbol->section_number = ABSOLUTE_SECTION_NUMBER;
-        symbol->value = value/* % 16*/;
+        symbol->value = value;
         
         symbol_record_external_symbol (symbol);