Added AMIGA Huge support
authorRobert Pengelly <robertapengelly@hotmail.com>
Thu, 12 Jun 2025 00:29:04 +0000 (01:29 +0100)
committerRobert Pengelly <robertapengelly@hotmail.com>
Thu, 12 Jun 2025 00:29:04 +0000 (01:29 +0100)
ranlib.c

index 15f6804e60b06a14af3a324ec275798da8e5a75b..89cbe8b275b5f7973e23628b49830eb15bb8a933 100644 (file)
--- a/ranlib.c
+++ b/ranlib.c
@@ -343,6 +343,127 @@ static void elf_get_symbols (void *object, long offset, int endianess) {
 
 }
 
+static void hunk_get_symbols (void *object, unsigned long bytes, long offset) {
+
+    unsigned char *pos = (unsigned char *) object + 4;
+    unsigned long name_size, size;
+    
+    struct strtab *strtab;
+    
+    name_size = array_to_integer (pos, 4);
+    name_size *= 4;
+    
+    pos = pos + 4 + name_size;
+    
+    while (pos < (unsigned char *) object + bytes) {
+    
+        if (pos[2] == 0x03 && pos[3] == 0xE7){
+            break;
+        }
+        
+        if (pos[2] == 0x03 && pos[3] == 0xF2) {
+        
+            pos += 4;
+            continue;
+        
+        }
+        
+        if (pos[2] == 0x03 && (pos[3] == 0xE8 || pos[3] == 0xE9 || pos[3] == 0xEA || pos[3] == 0xEB)) {
+        
+            pos += 4;
+            
+            if (pos[3] != 0xEB) {
+            
+                size = array_to_integer (pos, 4);
+                size *= 4;
+                
+                pos = pos + 4 + size;
+            
+            }
+            
+            continue;
+        
+        }
+        
+        if (pos[2] == 0x03 && pos[3] == 0xEF) {
+        
+            unsigned char symbol_type;
+            unsigned long num_ref;
+            
+            char *symname;
+            pos += 4;
+            
+            while (1) {
+            
+                name_size = array_to_integer (pos, 4);
+                pos += 4;
+                
+                if (name_size == 0) {
+                    break;
+                }
+                
+                symbol_type = (name_size >> 24) & 0xff;
+                
+                name_size &= 0xffffff;
+                name_size *= 4;
+                
+                symname = xstrndup ((char *) pos, name_size);
+                pos += name_size;
+                
+                if (symbol_type == 1 || symbol_type == 2) {
+                    pos += 4;
+                } else if (symbol_type == 129 || symbol_type == 130 || symbol_type == 136) {
+                
+                    if (symbol_type == 130) {
+                        pos += 4;
+                    }
+                    
+                    num_ref = array_to_integer (pos, 4);
+                    num_ref *= 4;
+                    
+                    pos = pos + 4 + num_ref;
+                
+                }
+                
+                strtab = xmalloc (sizeof (*strtab));
+                strtab->length = strlen (symname);
+                
+                strtab->name = symname;
+                strtab->offset = offset;
+                
+                add_strtab (&gstrtab, strtab);
+            
+            }
+            
+            continue;
+        
+        }
+        
+        if (pos[2] == 0x03 && pos[3] == 0xEC) {
+        
+            pos += 4;
+            
+            while (1) {
+            
+                size = array_to_integer (pos, 4) * 4;
+                pos += 4;
+                
+                if (size == 0) {
+                    break;
+                }
+                
+                pos = pos + size + 4;
+            
+            }
+            
+            continue;
+        
+        }
+    
+    }
+
+}
+
 #define     RECORD_TYPE_EXTDEF          0x8C
 #define     RECORD_TYPE_PUBDEF          0x90
 
@@ -514,6 +635,18 @@ void ranlib (void) {
         
         }
         
+        if (object[2] == 0x03 && object[3] == 0xE7) {
+        
+            hunk_get_symbols (object, real_size, offset + 8);
+            free (object);
+            
+            offset += sizeof (hdr);
+            offset += bytes;
+            
+            continue;
+        
+        }
+        
         if (object[0] == 0x07 && object[1] == 0x01) {
         
             aout_get_symbols (object, offset + 8);