Commit | Line | Data |
---|---|---|
0b652851 JN |
1 | This patch enables building binutils using TCC and Mes C Library |
2 | ||
3 | * disable building DOC | |
4 | * remove signed int trickery that does not work with TCC | |
5 | * fixe the malloc prototype to use size_t | |
6 | * add missing includes | |
7 | * remove C99'isms to avoid of mixing code and variable declaration | |
8 | * [MES_BOOTSTRAP]: remove strncmp to avoid duplicat symbol | |
9 | ||
10 | Upstream status: Not presented upstream. | |
11 | ||
12 | diff -purN -x config.status -x config.h -x BOOT ../binutils-2.20.1a/bfd/elf32-i386.c binutils-2.20.1a/bfd/elf32-i386.c | |
13 | --- ../binutils-2.20.1a/bfd/elf32-i386.c 2009-09-10 13:47:12.000000000 +0200 | |
14 | +++ binutils-2.20.1a/bfd/elf32-i386.c 2018-06-23 19:33:20.068134411 +0200 | |
15 | @@ -4254,6 +4254,7 @@ elf_i386_finish_dynamic_symbol (bfd *out | |
16 | if (!h->pointer_equality_needed) | |
17 | abort (); | |
18 | ||
19 | + { | |
20 | /* For non-shared object, we can't use .got.plt, which | |
21 | contains the real function addres if we need pointer | |
22 | equality. We load the GOT entry with the PLT entry. */ | |
23 | @@ -4262,6 +4263,7 @@ elf_i386_finish_dynamic_symbol (bfd *out | |
24 | (plt->output_section->vma | |
25 | + plt->output_offset + h->plt.offset), | |
26 | htab->elf.sgot->contents + h->got.offset); | |
27 | + } | |
28 | return TRUE; | |
29 | } | |
30 | } | |
31 | diff -purN -x config.status -x config.h -x BOOT ../binutils-2.20.1a/bfd/elfcode.h binutils-2.20.1a/bfd/elfcode.h | |
32 | --- ../binutils-2.20.1a/bfd/elfcode.h 2009-09-10 13:47:12.000000000 +0200 | |
33 | +++ binutils-2.20.1a/bfd/elfcode.h 2018-06-19 19:07:16.647627075 +0200 | |
34 | @@ -73,6 +73,7 @@ | |
35 | #include "bfdlink.h" | |
36 | #include "libbfd.h" | |
37 | #include "elf-bfd.h" | |
38 | +#include <limits.h> | |
39 | ||
40 | /* Renaming structures, typedefs, macros and functions to be size-specific. */ | |
41 | #define Elf_External_Ehdr NAME(Elf,External_Ehdr) | |
42 | @@ -706,8 +707,8 @@ elf_object_p (bfd *abfd) | |
43 | if (i_ehdrp->e_shnum != 1) | |
44 | { | |
45 | /* Check that we don't have a totally silly number of sections. */ | |
46 | - if (i_ehdrp->e_shnum > (unsigned int) -1 / sizeof (x_shdr) | |
47 | - || i_ehdrp->e_shnum > (unsigned int) -1 / sizeof (i_shdr)) | |
48 | + if (i_ehdrp->e_shnum > INT_MAX / sizeof (x_shdr) | |
49 | + || i_ehdrp->e_shnum > INT_MAX / sizeof (i_shdr)) | |
50 | goto got_wrong_format_error; | |
51 | ||
52 | where += (i_ehdrp->e_shnum - 1) * sizeof (x_shdr); | |
53 | diff -purN -x config.status -x config.h -x BOOT ../binutils-2.20.1a/bfd/Makefile.in binutils-2.20.1a/bfd/Makefile.in | |
54 | --- ../binutils-2.20.1a/bfd/Makefile.in 2010-03-03 14:59:15.000000000 +0100 | |
55 | +++ binutils-2.20.1a/bfd/Makefile.in 2018-06-16 14:00:46.297724081 +0200 | |
56 | @@ -320,7 +320,7 @@ ACLOCAL_AMFLAGS = -I . -I .. -I ../confi | |
57 | # RELEASE=y | |
58 | INCDIR = $(srcdir)/../include | |
59 | CSEARCH = -I. -I$(srcdir) -I$(INCDIR) | |
60 | -SUBDIRS = doc po | |
61 | +SUBDIRS = # these fail to build: doc po | |
62 | bfddocdir = doc | |
63 | libbfd_la_LDFLAGS = $(am__append_1) -release `cat libtool-soversion` \ | |
64 | @SHARED_LDFLAGS@ $(am__empty) | |
65 | diff -purN -x config.status -x config.h -x BOOT ../binutils-2.20.1a/binutils/arparse.c binutils-2.20.1a/binutils/arparse.c | |
66 | --- ../binutils-2.20.1a/binutils/arparse.c 2009-10-16 13:52:16.000000000 +0200 | |
67 | +++ binutils-2.20.1a/binutils/arparse.c 2018-06-19 01:30:00.576219981 +0200 | |
68 | @@ -330,7 +330,7 @@ YYID (i) | |
69 | # define YYMALLOC malloc | |
70 | # if ! defined malloc && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \ | |
71 | || defined __cplusplus || defined _MSC_VER) | |
72 | -void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */ | |
73 | +void *malloc (size_t); /* INFRINGES ON USER NAME SPACE */ | |
74 | # endif | |
75 | # endif | |
76 | # ifndef YYFREE | |
77 | diff -purN -x config.status -x config.h -x BOOT ../binutils-2.20.1a/binutils/dwarf.c binutils-2.20.1a/binutils/dwarf.c | |
78 | --- ../binutils-2.20.1a/binutils/dwarf.c 2009-09-14 13:43:26.000000000 +0200 | |
79 | +++ binutils-2.20.1a/binutils/dwarf.c 2018-06-16 14:01:45.162684662 +0200 | |
80 | @@ -27,6 +27,10 @@ | |
81 | #include "dwarf2.h" | |
82 | #include "dwarf.h" | |
83 | ||
84 | +#if MES_BOOTSTRAP | |
85 | +#include "getopt.h" | |
86 | +#endif | |
87 | + | |
88 | static int have_frame_base; | |
89 | static int need_base_address; | |
90 | ||
91 | diff -purN -x config.status -x config.h -x BOOT ../binutils-2.20.1a/binutils/sysinfo.c binutils-2.20.1a/binutils/sysinfo.c | |
92 | --- ../binutils-2.20.1a/binutils/sysinfo.c 2009-10-16 13:52:17.000000000 +0200 | |
93 | +++ binutils-2.20.1a/binutils/sysinfo.c 2018-06-19 01:29:23.823612807 +0200 | |
94 | @@ -286,7 +286,7 @@ YYID (i) | |
95 | # define YYMALLOC malloc | |
96 | # if ! defined malloc && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \ | |
97 | || defined __cplusplus || defined _MSC_VER) | |
98 | -void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */ | |
99 | +void *malloc (size_t); /* INFRINGES ON USER NAME SPACE */ | |
100 | # endif | |
101 | # endif | |
102 | # ifndef YYFREE | |
103 | diff -purN -x config.status -x config.h -x BOOT ../binutils-2.20.1a/gas/config/tc-i386.c binutils-2.20.1a/gas/config/tc-i386.c | |
104 | --- ../binutils-2.20.1a/gas/config/tc-i386.c 2009-09-14 13:43:27.000000000 +0200 | |
105 | +++ binutils-2.20.1a/gas/config/tc-i386.c 2018-06-23 19:39:37.546254752 +0200 | |
106 | @@ -4869,6 +4869,7 @@ build_modrm_byte (void) | |
107 | if (vex_3_sources) | |
108 | { | |
109 | unsigned int nds, reg; | |
110 | + expressionS *exp; | |
111 | ||
112 | if (i.tm.opcode_modifier.veximmext | |
113 | && i.tm.opcode_modifier.immext) | |
114 | @@ -4892,7 +4893,7 @@ build_modrm_byte (void) | |
115 | ||
116 | /* Generate an 8bit immediate operand to encode the register | |
117 | operand. */ | |
118 | - expressionS *exp = &im_expressions[i.imm_operands++]; | |
119 | + exp = &im_expressions[i.imm_operands++]; | |
120 | i.op[i.operands].imms = exp; | |
121 | i.types[i.operands] = imm8; | |
122 | i.operands++; | |
123 | diff -purN -x config.status -x config.h -x BOOT ../binutils-2.20.1a/ld/ldgram.c binutils-2.20.1a/ld/ldgram.c | |
124 | --- ../binutils-2.20.1a/ld/ldgram.c 2009-10-16 13:52:15.000000000 +0200 | |
125 | +++ binutils-2.20.1a/ld/ldgram.c 2018-06-19 01:30:57.809165437 +0200 | |
126 | @@ -561,7 +561,7 @@ YYID (i) | |
127 | # define YYMALLOC malloc | |
128 | # if ! defined malloc && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \ | |
129 | || defined __cplusplus || defined _MSC_VER) | |
130 | -void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */ | |
131 | +void *malloc (size_t); /* INFRINGES ON USER NAME SPACE */ | |
132 | # endif | |
133 | # endif | |
134 | # ifndef YYFREE | |
135 | diff -purN -x config.status -x config.h -x BOOT ../binutils-2.20.1a/libiberty/strncmp.c binutils-2.20.1a/libiberty/strncmp.c | |
136 | --- ../binutils-2.20.1a/libiberty/strncmp.c 2005-03-28 04:09:01.000000000 +0200 | |
137 | +++ binutils-2.20.1a/libiberty/strncmp.c 2018-06-23 19:19:50.038992482 +0200 | |
138 | @@ -15,6 +15,13 @@ Compares the first @var{n} bytes of two | |
139 | #include <ansidecl.h> | |
140 | #include <stddef.h> | |
141 | ||
142 | +#if !MES_BOOTSTRAP | |
143 | + | |
144 | +/* | |
145 | + libtool: link: /gnu/store/rgwjixk5zl7s2d3xsb2ws2z2q3m0xjm4-tcc-boot-0.9.26-0.97196ce/bin/tcc -D __GLIBC_MINOR__=6 -D MES_BOOTSTRAP=1 -g -o size size.o bucomm.o version.o filemode.o ../bfd/.libs/libbfd.a ../libiberty/libiberty.a ./../intl/libintl.a | |
146 | + /gnu/store/rgwjixk5zl7s2d3xsb2ws2z2q3m0xjm4-tcc-boot-0.9.26-0.97196ce/lib/libc.a: error: 'strncmp' defined twice | |
147 | +*/ | |
148 | + | |
149 | int | |
150 | strncmp(const char *s1, const char *s2, register size_t n) | |
151 | { | |
152 | @@ -31,3 +38,5 @@ strncmp(const char *s1, const char *s2, | |
153 | } | |
154 | return 0; | |
155 | } | |
156 | + | |
157 | +#endif // !MES_BOOTSTRAP |