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
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);
/******************************************************************************
* @file elf.c
*****************************************************************************/
+#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "elf.h"
#include "report.h"
#include "section.h"
-#include "stdint.h"
#include "symbol.h"
#define UNNAMED_SYMBOL_NAME "(unnamed)"
}
-#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) {
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 */
+++ /dev/null
-/******************************************************************************
- * @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"
-
} 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) {
#define _LD_H
#define FAKE_LD_FILENAME "autogenerated"
-#include "stdint.h"
+#include <stdint.h>
struct ld_state {
#include <ctype.h>
#include <errno.h>
#include <limits.h>
+#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "mz.h"
#include "pe.h"
#include "report.h"
-#include "stdint.h"
struct options_with_use {
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;
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;
#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);
*****************************************************************************/
#include <limits.h>
#include <stdio.h>
+#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#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) {
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) {
}
integer_to_array (result, p->part->content + p->reloc_entry->offset, 8, 0);
-
-#endif
}
/******************************************************************************
* @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"
#ifndef _SECTION_H
#define _SECTION_H
+#include <stdint.h>
+
#include "reloc.h"
-#include "stdint.h"
#include "symbol.h"
struct object_file {
+++ /dev/null
-/******************************************************************************
- * @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 */
-
#ifndef _SYMBOL_H
#define _SYMBOL_H
+#include <stdint.h>
#include "section.h"
-#include "stdint.h"
struct symbol {