Removed C90 limitations and NO_LONG_LONG related stuff as even MinGW on Windows 2000... master
authorRobert Pengelly <robertapengelly@hotmail.com>
Wed, 19 Aug 2026 11:37:26 +0000 (12:37 +0100)
committerRobert Pengelly <robertapengelly@hotmail.com>
Wed, 19 Aug 2026 11:37:26 +0000 (12:37 +0100)
15 files changed:
Makefile.unix
axe.c
elf.c
elf.h
inttypes.h [deleted file]
ld.c
ld.h
lib.c
lib.h
link.c
macho.c
map.c
section.h
stdint.h [deleted file]
symbol.h

index 7a4c91cbec96533b9d798c28a1c82b2763f2061b..a13768ca85070650fa005d0774e5cef67a0b1dbc 100644 (file)
@@ -5,7 +5,7 @@ SRCDIR              ?=  $(CURDIR)
 VPATH               :=  $(SRCDIR)
 
 CC                  :=  gcc
-CFLAGS              :=  -D_FILE_OFFSET_BITS=64 -O2 -Wall -Werror -Wextra -ansi -pedantic -std=c90
+CFLAGS              :=  -D_FILE_OFFSET_BITS=64 -O2 -Wall -Werror -Wextra
 
 CSRC                :=  aout.c axe.c coff.c dx.c elf.c elks.c hashtab.c ld.c lib.c link.c ll.c macho.c map.c mz.c omf.c pe.c report.c section.c symbol.c vector.c write7x.c
 
diff --git a/axe.c b/axe.c
index 5aff0a47b069fb4f8397b0c132b0e2293cd84c31..99d66f75a03608b5cd51195581e5ed4597e2dc59 100644 (file)
--- a/axe.c
+++ b/axe.c
@@ -260,27 +260,12 @@ static unsigned char *write_relocs_for_section64 (unsigned char *pos, struct sec
                 r_symbolnum = AXE_TEXT;
             }
             
-#if     ((ULONG_MAX >> 16) >> 16) == 0xffffffff
-            if ((part->reloc_arr[i].r_symbolnum >> 27) & 1) {
-                r_symbolnum |= (1LU << 59);
-            }
-            
-            integer_to_array (r_symbolnum | (size_log2 << 57), rel.r_symbolnum, 8, 0);
-#elif   defined (NO_LONG_LONG)
-            integer_to_array (r_symbolnum, rel.r_symbolnum, 4, 0);
-            
-            if ((part->reloc_arr[i].r_symbolnum >> 27) & 1) {
-                r_symbolnum = (1LU << 27);
-            }
-            
-            integer_to_array (r_symbolnum | (size_log2 << 25), rel.r_symbolnum + 4, 4, 0);
-#else
             if ((part->reloc_arr[i].r_symbolnum >> 27) & 1) {
                 r_symbolnum |= (1LLU << 59);
             }
             
             integer_to_array (r_symbolnum | (size_log2 << 57), rel.r_symbolnum, 8, 0);
-#endif
+            
             memcpy (pos, &rel, sizeof (rel));
             pos += sizeof (rel);
         
diff --git a/elf.c b/elf.c
index 760e80e5bd232f6ef604f3a75e7a2e1787f24d26..ef5ed1b2a9d7c22e9ae7448512b6f627adb5b0c0 100644 (file)
--- a/elf.c
+++ b/elf.c
@@ -1,6 +1,7 @@
 /******************************************************************************
  * @file            elf.c
  *****************************************************************************/
+#include    <stdint.h>
 #include    <stdio.h>
 #include    <stdlib.h>
 #include    <string.h>
@@ -10,7 +11,6 @@
 #include    "elf.h"
 #include    "report.h"
 #include    "section.h"
-#include    "stdint.h"
 #include    "symbol.h"
 
 #define     UNNAMED_SYMBOL_NAME         "(unnamed)"
@@ -84,29 +84,19 @@ static void translate_relocation (const char *filename, struct reloc_entry *relo
 
 }
 
-#ifndef     NO_LONG_LONG
-# define        ELF64_R_SYM(i)          ((i) >> 32)
-# define        ELF64_R_TYPE(i)         ((i) & 0xffffffff)
-#endif
+#define         ELF64_R_SYM(i)          ((i) >> 32)
+#define         ELF64_R_TYPE(i)         ((i) & 0xffffffff)
 
 static void translate_relocation64_addend (const char *filename, struct reloc_entry *reloc, struct elf64_rela *input_reloc, struct section_part *part, int endianess) {
 
     uint64_t r_info, r_offset;
     uint32_t symbol_index, rel_type;
     
-#if     defined (NO_LONG_LONG)
-    r_info = array_to_integer (input_reloc->r_info + 4, 4, endianess);
-    r_offset = array_to_integer (input_reloc->r_offset, 4, endianess);
-    
-    rel_type = array_to_integer (input_reloc->r_info, 4, endianess);
-    symbol_index = r_info;
-#else
     r_info = array_to_integer (input_reloc->r_info, 8, endianess);
     r_offset = array_to_integer (input_reloc->r_offset, 8, endianess);
     
     symbol_index = ELF64_R_SYM (r_info);
     rel_type = ELF64_R_TYPE (r_info);
-#endif
     
     if (symbol_index >= part->of->symbol_cnt) {
     
diff --git a/elf.h b/elf.h
index e8220198843c962a9cc5b9b054c53a2556a06d1e..e10a44b32f840ca158455ab979c603eaae4a5eee 100644 (file)
--- a/elf.h
+++ b/elf.h
@@ -217,7 +217,7 @@ void elf32_write (const char *filename);
 void read_elf64_object (const char *filename, unsigned char *data, unsigned long data_size, int endianess);
 void elf64_write (const char *filename);
 
-#include    "stdint.h"
+#include    <stdint.h>
 uint64_t elf_get_first_section_rva (void);
 
 #endif      /* _ELF_H */
diff --git a/inttypes.h b/inttypes.h
deleted file mode 100644 (file)
index 2ff8fed..0000000
+++ /dev/null
@@ -1,24 +0,0 @@
-/******************************************************************************
- * @file            inttypes.h
- *****************************************************************************/
-#include    <limits.h>
-
-#if     defined (NO_LONG_LONG)
-# define    I64_FMT                     "l"
-#elif   defined (_MSVC_)
-# define    I64_FMT                     "I64"
-#elif   defined (__PRI_64_LENGTH_MODIFIER__)                                                        /* Mac */
-# define    I64_FMT                     __PRI_64_LENGTH_MODIFIER__
-#elif   (defined (SIZEOF_LONG) && SIZEOF_LONG >= 8) || ((ULONG_MAX >> 16) >> 16) == 0xffffffff
-# define    I64_FMT                     "l"
-#else
-# define    I64_FMT                     "ll"
-#endif
-
-#define     PRId64                      I64_FMT"d"
-#define     PRIi64                      I64_FMT"i"
-#define     PRIo64                      I64_FMT"o"
-#define     PRIu64                      I64_FMT"u"
-#define     PRIx64                      I64_FMT"x"
-#define     PRIX64                      I64_FMT"X"
-
diff --git a/ld.c b/ld.c
index 827d51323b2cc4e2a6c7377ed889fb4592a24ea4..cb87f8bd80f4d24fbaae658d09603da14b06200b 100644 (file)
--- a/ld.c
+++ b/ld.c
@@ -540,19 +540,12 @@ int main (int argc, char **argv) {
         
         } else if (state->format == LD_FORMAT_AMD64_ELF || state->format == LD_FORMAT_I386_ELF) {
             state->base_address = 0x0040000;
-#if     defined(NO_LONG_LONG)
-        } else if (state->format == LD_FORMAT_AMD64_MACHO || state->format == LD_FORMAT_AARCH64_MACHO) {
-            state->base_address = 0x10000000;
-        } else if (state->format == LD_FORMAT_AARCH64_ELF) {
-            state->base_address = 0x14000000;
-        }
-#else
         } else if (state->format == LD_FORMAT_AMD64_MACHO || state->format == LD_FORMAT_AARCH64_MACHO) {
             state->base_address = 0x100000000;
         } else if (state->format == LD_FORMAT_AARCH64_ELF) {
             state->base_address = 0x140000000;
         }
-#endif
+    
     }
     
     if (state->format == LD_FORMAT_I386_AOUT) {
diff --git a/ld.h b/ld.h
index e5f6f92efdec0cc257efd9b70303c8bd81edb5f8..77a2c269c712f650fa78e1e34542640b8f77e729 100644 (file)
--- a/ld.h
+++ b/ld.h
@@ -5,7 +5,7 @@
 #define     _LD_H
 
 #define     FAKE_LD_FILENAME            "autogenerated"
-#include    "stdint.h"
+#include    <stdint.h>
 
 struct ld_state {
 
diff --git a/lib.c b/lib.c
index ddb33a0b4327e7ba72d94860578441b8aa7ad695..3136f1813a85d0469fcb7f0efbba29b21bb2de5f 100644 (file)
--- a/lib.c
+++ b/lib.c
@@ -4,6 +4,7 @@
 #include    <ctype.h>
 #include    <errno.h>
 #include    <limits.h>
+#include    <stdint.h>
 #include    <stdio.h>
 #include    <stdlib.h>
 #include    <string.h>
@@ -15,7 +16,6 @@
 #include    "mz.h"
 #include    "pe.h"
 #include    "report.h"
-#include    "stdint.h"
 
 struct options_with_use {
 
@@ -534,10 +534,6 @@ uint64_t array_to_integer (unsigned char *arr, int size, int big_endian) {
     uint64_t value = 0;
     int i;
     
-#if     defined (NO_LONG_LONG) && ((ULONG_MAX >> 16) >> 16) < 0xffffffff
-    if (size == 8) { size = 4; }
-#endif
-    
     if (big_endian) {
     
         int j;
@@ -560,10 +556,6 @@ uint64_t array_to_integer (unsigned char *arr, int size, int big_endian) {
 
 void integer_to_array (uint64_t value, unsigned char *dest, int size, int big_endian) {
 
-#if     defined (NO_LONG_LONG) && ((ULONG_MAX >> 16) >> 16) < 0xffffffff
-    if (size == 8) { size = 4; }
-#endif
-    
     if (big_endian) {
     
         int i, j;
diff --git a/lib.h b/lib.h
index c32f6d05601f6b79d706ad0b64b8a8d2f5125ff0..bc8a34ca25a001dc3d9defd8c89f4f62fbe262b1 100644 (file)
--- a/lib.h
+++ b/lib.h
@@ -19,7 +19,7 @@ struct ld_option {
 #define     LD_OPTION_NO_ARG            0
 #define     LD_OPTION_HAS_ARG           1
 
-#include    "stdint.h"
+#include    <stdint.h>
 
 uint64_t array_to_integer (unsigned char *arr, int size, int big_endian);
 void integer_to_array (uint64_t value, unsigned char *dest, int size, int big_endian);
diff --git a/link.c b/link.c
index a14070237107c1974e063af1a9a98ab26b7db067..7c480116e2a3984d6a76fc8ee2c3e8c372a5aaee 100644 (file)
--- a/link.c
+++ b/link.c
@@ -3,6 +3,7 @@
  *****************************************************************************/
 #include    <limits.h>
 #include    <stdio.h>
+#include    <stdint.h>
 #include    <stdlib.h>
 #include    <string.h>
 
@@ -14,7 +15,6 @@
 #include    "reloc.h"
 #include    "report.h"
 #include    "section.h"
-#include    "stdint.h"
 #include    "symbol.h"
 
 static uint64_t generic_read (struct section_part *part, struct reloc_entry *rel) {
diff --git a/macho.c b/macho.c
index b020ad2caba0c39753724ade1778eb89b578f878..0a07954c0d3404e5e5a64ec657d2ae7350a0a8ef 100644 (file)
--- a/macho.c
+++ b/macho.c
@@ -1044,31 +1044,6 @@ static void calculate_chained_fixups (struct chained_fixup_starts *cfs, int doin
             uint64_t result = array_to_integer (p->part->content + p->reloc_entry->offset, 8, 0);
             result -= state->base_address;
             
-#if     defined (NO_LONG_LONG) && ((ULONG_MAX >> 16) >> 16) < 0xffffffff
-
-            integer_to_array (result, p->part->content + p->reloc_entry->offset, 4, 0);
-            
-            if (p + 1 != part_rels + num_relocs) {
-            
-                uint64_t rva1, rva2;
-                
-                rva1 = p->part->rva + p->reloc_entry->offset;
-                rva2 = p[1].part->rva + p[1].reloc_entry->offset;
-                
-                if (FLOOR_TO (rva1, PAGE_SIZE) != FLOOR_TO (rva2, PAGE_SIZE)) {
-                
-                    p++;
-                    break;
-                
-                }
-                
-                result = (((rva2 - rva1) / 4) & 0xfff) << 19;
-                integer_to_array (result, p->part->content + p->reloc_entry->offset + 4, 4, 0);
-            
-            }
-
-#else
-
             result &= 0xfffffffff;
             
             if (p + 1 != part_rels + num_relocs) {
@@ -1092,8 +1067,6 @@ static void calculate_chained_fixups (struct chained_fixup_starts *cfs, int doin
             }
             
             integer_to_array (result, p->part->content + p->reloc_entry->offset, 8, 0);
-
-#endif
         
         }
     
diff --git a/map.c b/map.c
index f0ba5a1b8b05791379cbd4d9e5e424ce201dafa7..ce723c309e99bf9c593e3072b428e6ebd11bcb59 100644 (file)
--- a/map.c
+++ b/map.c
@@ -1,13 +1,12 @@
 /******************************************************************************
  * @file            map.c
  *****************************************************************************/
-#include    "stdint.h"
-
+#include    <inttypes.h>
+#include    <stdint.h>
 #include    <stdio.h>
 #include    <stdlib.h>
 #include    <string.h>
 
-#include    "inttypes.h"
 #include    "ld.h"
 #include    "report.h"
 #include    "section.h"
index e72e827af45bef0702d44e3cd29c65fd79c8a313..4a92e65f4dacdffaa0301616c3f0e3dc5aafca19 100644 (file)
--- a/section.h
+++ b/section.h
@@ -4,8 +4,9 @@
 #ifndef     _SECTION_H
 #define     _SECTION_H
 
+#include    <stdint.h>
+
 #include    "reloc.h"
-#include    "stdint.h"
 #include    "symbol.h"
 
 struct object_file {
diff --git a/stdint.h b/stdint.h
deleted file mode 100644 (file)
index 164c733..0000000
--- a/stdint.h
+++ /dev/null
@@ -1,50 +0,0 @@
-/******************************************************************************
- * @file            stdint.h
- *****************************************************************************/
-#ifndef     _STDINT_H_INCLUDED
-#ifndef     _STDINT_H
-#ifndef     _STDINT_H_
-
-#define     _STDINT_H_INCLUDED
-#define     _STDINT_H
-#define     _STDINT_H_
-
-#include    <limits.h>
-
-/* Add all data types (even though we don't use them) as the project seems to fail to build on some systems. */
-typedef     signed char                 int8_t;
-typedef     unsigned char               uint8_t;
-
-typedef     signed short                int16_t;
-typedef     unsigned short              uint16_t;
-
-#if     INT_MAX > 32767
-typedef     signed int                  int32_t;
-typedef     unsigned int                uint32_t;
-#else
-typedef     signed long                 int32_t;
-typedef     unsigned long               uint32_t;
-#endif
-
-#ifndef     _INT64_T
-#define     _INT64_T
-#if     defined (NO_LONG_LONG) || ((ULONG_MAX >> 16) >> 16) == 0xffffffff
-typedef     signed long                 int64_t;
-#else
-typedef     signed long long            int64_t;
-#endif
-#endif      /* _INT64_T */
-
-#ifndef     _UINT64_T
-#define     _UINT64_T
-#if     defined (NO_LONG_LONG) || ((ULONG_MAX >> 16) >> 16) == 0xffffffff
-typedef     unsigned long               uint64_t;
-#else
-typedef     unsigned long long          uint64_t;
-#endif
-#endif      /* _UINT64_T */
-
-#endif      /* _STDINT_H_ */
-#endif      /* _STDINT_H */
-#endif      /* _STDINT_H_INCLUDED */
-
index 6cc39c234fa27bf006b28d7f4473d51057d321cb..08233132b4575ac8c7fdbdec8fba14479c01ef84 100644 (file)
--- a/symbol.h
+++ b/symbol.h
@@ -4,8 +4,8 @@
 #ifndef     _SYMBOL_H
 #define     _SYMBOL_H
 
+#include    <stdint.h>
 #include    "section.h"
-#include    "stdint.h"
 
 struct symbol {