diff options
author | Sam Ravnborg <sam@ravnborg.org> | 2012-05-14 13:35:50 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2012-05-14 17:05:10 -0400 |
commit | 51f19cfa76d7d20ec767719a427e3d4f450fd5de (patch) | |
tree | 127918024b3282271585422d0365ae2524f7bcf0 /arch/sparc | |
parent | 50544bce4c46561fe9d3f817941bd95d8ae6fedd (diff) |
sparc32: drop build time btfixup patching
Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'arch/sparc')
-rw-r--r-- | arch/sparc/Makefile | 12 | ||||
-rw-r--r-- | arch/sparc/boot/Makefile | 61 | ||||
-rw-r--r-- | arch/sparc/boot/btfixupprep.c | 386 |
3 files changed, 10 insertions, 449 deletions
diff --git a/arch/sparc/Makefile b/arch/sparc/Makefile index cd2afcc6ecf5..7e8040b4504c 100644 --- a/arch/sparc/Makefile +++ b/arch/sparc/Makefile | |||
@@ -33,11 +33,6 @@ UTS_MACHINE := sparc | |||
33 | KBUILD_CFLAGS += -m32 -mcpu=v7 -pipe -mno-fpu -fcall-used-g5 -fcall-used-g7 | 33 | KBUILD_CFLAGS += -m32 -mcpu=v7 -pipe -mno-fpu -fcall-used-g5 -fcall-used-g7 |
34 | KBUILD_AFLAGS += -m32 -Wa,-Av8 | 34 | KBUILD_AFLAGS += -m32 -Wa,-Av8 |
35 | 35 | ||
36 | #LDFLAGS_vmlinux = -N -Ttext 0xf0004000 | ||
37 | # Since 2.5.40, the first stage is left not btfix-ed. | ||
38 | # Actual linking is done with "make image". | ||
39 | LDFLAGS_vmlinux = -r | ||
40 | |||
41 | else | 36 | else |
42 | ##### | 37 | ##### |
43 | # sparc64 | 38 | # sparc64 |
@@ -72,13 +67,6 @@ libs-y += arch/sparc/lib/ | |||
72 | 67 | ||
73 | drivers-$(CONFIG_OPROFILE) += arch/sparc/oprofile/ | 68 | drivers-$(CONFIG_OPROFILE) += arch/sparc/oprofile/ |
74 | 69 | ||
75 | # Export what is needed by arch/sparc/boot/Makefile | ||
76 | export VMLINUX_INIT VMLINUX_MAIN | ||
77 | VMLINUX_INIT := $(head-y) $(init-y) | ||
78 | VMLINUX_MAIN := $(core-y) kernel/ mm/ fs/ ipc/ security/ crypto/ block/ | ||
79 | VMLINUX_MAIN += $(patsubst %/, %/lib.a, $(libs-y)) $(libs-y) | ||
80 | VMLINUX_MAIN += $(drivers-y) $(net-y) | ||
81 | |||
82 | ifdef CONFIG_KALLSYMS | 70 | ifdef CONFIG_KALLSYMS |
83 | export kallsyms.o := .tmp_kallsyms2.o | 71 | export kallsyms.o := .tmp_kallsyms2.o |
84 | endif | 72 | endif |
diff --git a/arch/sparc/boot/Makefile b/arch/sparc/boot/Makefile index d56d199c1aa8..6e63afb128d9 100644 --- a/arch/sparc/boot/Makefile +++ b/arch/sparc/boot/Makefile | |||
@@ -6,8 +6,8 @@ | |||
6 | ROOT_IMG := /usr/src/root.img | 6 | ROOT_IMG := /usr/src/root.img |
7 | ELFTOAOUT := elftoaout | 7 | ELFTOAOUT := elftoaout |
8 | 8 | ||
9 | hostprogs-y := piggyback btfixupprep | 9 | hostprogs-y := piggyback |
10 | targets := tftpboot.img btfix.o btfix.S image zImage vmlinux.aout | 10 | targets := tftpboot.img image zImage vmlinux.aout |
11 | clean-files := System.map | 11 | clean-files := System.map |
12 | 12 | ||
13 | quiet_cmd_elftoaout = ELFTOAOUT $@ | 13 | quiet_cmd_elftoaout = ELFTOAOUT $@ |
@@ -17,58 +17,9 @@ quiet_cmd_piggy = PIGGY $@ | |||
17 | quiet_cmd_strip = STRIP $@ | 17 | quiet_cmd_strip = STRIP $@ |
18 | cmd_strip = $(STRIP) -R .comment -R .note -K sun4u_init -K _end -K _start $< -o $@ | 18 | cmd_strip = $(STRIP) -R .comment -R .note -K sun4u_init -K _end -K _start $< -o $@ |
19 | 19 | ||
20 | ifeq ($(CONFIG_SPARC32),y) | ||
21 | quiet_cmd_btfix = BTFIX $@ | ||
22 | cmd_btfix = $(OBJDUMP) -x vmlinux | $(obj)/btfixupprep > $@ | ||
23 | quiet_cmd_sysmap = SYSMAP $(obj)/System.map | ||
24 | cmd_sysmap = $(CONFIG_SHELL) $(srctree)/scripts/mksysmap | ||
25 | quiet_cmd_image = LD $@ | ||
26 | cmd_image = $(LD) $(LDFLAGS) $(EXTRA_LDFLAGS) $(LDFLAGS_$(@F)) -o $@ | ||
27 | |||
28 | define rule_image | ||
29 | $(if $($(quiet)cmd_image), \ | ||
30 | echo ' $($(quiet)cmd_image)' &&) \ | ||
31 | $(cmd_image); \ | ||
32 | $(if $($(quiet)cmd_sysmap), \ | ||
33 | echo ' $($(quiet)cmd_sysmap)' &&) \ | ||
34 | $(cmd_sysmap) $@ $(obj)/System.map; \ | ||
35 | if [ $$? -ne 0 ]; then \ | ||
36 | rm -f $@; \ | ||
37 | /bin/false; \ | ||
38 | fi; \ | ||
39 | echo 'cmd_$@ := $(cmd_image)' > $(@D)/.$(@F).cmd | ||
40 | endef | ||
41 | |||
42 | BTOBJS := $(patsubst %/, %/built-in.o, $(VMLINUX_INIT)) | ||
43 | BTLIBS := $(patsubst %/, %/built-in.o, $(VMLINUX_MAIN)) | ||
44 | LDFLAGS_image := -T arch/sparc/kernel/vmlinux.lds $(BTOBJS) \ | ||
45 | --start-group $(BTLIBS) --end-group \ | ||
46 | $(kallsyms.o) $(obj)/btfix.o | ||
47 | |||
48 | # Link the final image including btfixup'ed symbols. | ||
49 | # This is a replacement for the link done in the top-level Makefile. | ||
50 | # Note: No dependency on the prerequisite files since that would require | ||
51 | # make to try check if they are updated - and due to changes | ||
52 | # in gcc options (path for example) this would result in | ||
53 | # these files being recompiled for each build. | ||
54 | $(obj)/image: $(obj)/btfix.o FORCE | ||
55 | $(call if_changed_rule,image) | ||
56 | |||
57 | $(obj)/zImage: $(obj)/image | ||
58 | $(call if_changed,strip) | ||
59 | @echo ' kernel: $@ is ready' | ||
60 | |||
61 | $(obj)/btfix.S: $(obj)/btfixupprep vmlinux FORCE | ||
62 | $(call if_changed,btfix) | ||
63 | |||
64 | endif | ||
65 | |||
66 | ifeq ($(CONFIG_SPARC64),y) | 20 | ifeq ($(CONFIG_SPARC64),y) |
67 | 21 | ||
68 | # Actual linking | 22 | # Actual linking |
69 | $(obj)/image: vmlinux FORCE | ||
70 | $(call if_changed,strip) | ||
71 | @echo ' kernel: $@ is ready' | ||
72 | 23 | ||
73 | $(obj)/zImage: $(obj)/image | 24 | $(obj)/zImage: $(obj)/image |
74 | $(call if_changed,gzip) | 25 | $(call if_changed,gzip) |
@@ -79,6 +30,10 @@ $(obj)/vmlinux.aout: vmlinux FORCE | |||
79 | @echo ' kernel: $@ is ready' | 30 | @echo ' kernel: $@ is ready' |
80 | else | 31 | else |
81 | 32 | ||
33 | $(obj)/zImage: $(obj)/image | ||
34 | $(call if_changed,strip) | ||
35 | @echo ' kernel: $@ is ready' | ||
36 | |||
82 | # The following lines make a readable image for U-Boot. | 37 | # The following lines make a readable image for U-Boot. |
83 | # uImage - Binary file read by U-boot | 38 | # uImage - Binary file read by U-boot |
84 | # uImage.o - object file of uImage for loading with a | 39 | # uImage.o - object file of uImage for loading with a |
@@ -107,6 +62,10 @@ $(obj)/uImage: $(obj)/image.gz | |||
107 | 62 | ||
108 | endif | 63 | endif |
109 | 64 | ||
65 | $(obj)/image: vmlinux FORCE | ||
66 | $(call if_changed,strip) | ||
67 | @echo ' kernel: $@ is ready' | ||
68 | |||
110 | $(obj)/tftpboot.img: $(obj)/image $(obj)/piggyback System.map $(ROOT_IMG) FORCE | 69 | $(obj)/tftpboot.img: $(obj)/image $(obj)/piggyback System.map $(ROOT_IMG) FORCE |
111 | $(call if_changed,elftoaout) | 70 | $(call if_changed,elftoaout) |
112 | $(call if_changed,piggy) | 71 | $(call if_changed,piggy) |
diff --git a/arch/sparc/boot/btfixupprep.c b/arch/sparc/boot/btfixupprep.c deleted file mode 100644 index da031159e2b7..000000000000 --- a/arch/sparc/boot/btfixupprep.c +++ /dev/null | |||
@@ -1,386 +0,0 @@ | |||
1 | /* | ||
2 | Simple utility to prepare vmlinux image for sparc. | ||
3 | Resolves all BTFIXUP uses and settings and creates | ||
4 | a special .s object to link to the image. | ||
5 | |||
6 | Copyright (C) 1998 Jakub Jelinek (jj@sunsite.mff.cuni.cz) | ||
7 | |||
8 | This program is free software; you can redistribute it and/or modify | ||
9 | it under the terms of the GNU General Public License as published by | ||
10 | the Free Software Foundation; either version 2 of the License, or | ||
11 | (at your option) any later version. | ||
12 | |||
13 | This program is distributed in the hope that it will be useful, | ||
14 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
16 | GNU General Public License for more details. | ||
17 | |||
18 | You should have received a copy of the GNU General Public License | ||
19 | along with this program; if not, write to the Free Software | ||
20 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ | ||
21 | |||
22 | #include <stdio.h> | ||
23 | #include <string.h> | ||
24 | #include <ctype.h> | ||
25 | #include <errno.h> | ||
26 | #include <unistd.h> | ||
27 | #include <stdlib.h> | ||
28 | #include <malloc.h> | ||
29 | |||
30 | #define MAXSYMS 1024 | ||
31 | |||
32 | static char *symtab = "SYMBOL TABLE:"; | ||
33 | static char *relrec = "RELOCATION RECORDS FOR ["; | ||
34 | static int rellen; | ||
35 | static int symlen; | ||
36 | int mode; | ||
37 | |||
38 | struct _btfixup; | ||
39 | |||
40 | typedef struct _btfixuprel { | ||
41 | char *sect; | ||
42 | unsigned long offset; | ||
43 | struct _btfixup *f; | ||
44 | int frel; | ||
45 | struct _btfixuprel *next; | ||
46 | } btfixuprel; | ||
47 | |||
48 | typedef struct _btfixup { | ||
49 | int type; | ||
50 | int setinitval; | ||
51 | unsigned int initval; | ||
52 | char *initvalstr; | ||
53 | char *name; | ||
54 | btfixuprel *rel; | ||
55 | } btfixup; | ||
56 | |||
57 | btfixup array[MAXSYMS]; | ||
58 | int last = 0; | ||
59 | char buffer[1024]; | ||
60 | unsigned long lastfoffset = -1; | ||
61 | unsigned long lastfrelno; | ||
62 | btfixup *lastf; | ||
63 | |||
64 | static void fatal(void) __attribute__((noreturn)); | ||
65 | static void fatal(void) | ||
66 | { | ||
67 | fprintf(stderr, "Malformed output from objdump\n%s\n", buffer); | ||
68 | exit(1); | ||
69 | } | ||
70 | |||
71 | static btfixup *find(int type, char *name) | ||
72 | { | ||
73 | int i; | ||
74 | for (i = 0; i < last; i++) { | ||
75 | if (array[i].type == type && !strcmp(array[i].name, name)) | ||
76 | return array + i; | ||
77 | } | ||
78 | array[last].type = type; | ||
79 | array[last].name = strdup(name); | ||
80 | array[last].setinitval = 0; | ||
81 | if (!array[last].name) fatal(); | ||
82 | array[last].rel = NULL; | ||
83 | last++; | ||
84 | if (last >= MAXSYMS) { | ||
85 | fprintf(stderr, "Ugh. Something strange. More than %d different BTFIXUP symbols\n", MAXSYMS); | ||
86 | exit(1); | ||
87 | } | ||
88 | return array + last - 1; | ||
89 | } | ||
90 | |||
91 | static void set_mode (char *buffer) | ||
92 | { | ||
93 | for (mode = 0;; mode++) | ||
94 | if (buffer[mode] < '0' || buffer[mode] > '9') | ||
95 | break; | ||
96 | if (mode != 8 && mode != 16) | ||
97 | fatal(); | ||
98 | } | ||
99 | |||
100 | |||
101 | int main(int argc,char **argv) | ||
102 | { | ||
103 | char *p, *q; | ||
104 | char *sect; | ||
105 | int i, j, k; | ||
106 | unsigned int initval; | ||
107 | int shift; | ||
108 | btfixup *f; | ||
109 | btfixuprel *r, **rr; | ||
110 | unsigned long offset; | ||
111 | char *initvalstr; | ||
112 | |||
113 | symlen = strlen(symtab); | ||
114 | while (fgets (buffer, 1024, stdin) != NULL) | ||
115 | if (!strncmp (buffer, symtab, symlen)) | ||
116 | goto main0; | ||
117 | fatal(); | ||
118 | main0: | ||
119 | rellen = strlen(relrec); | ||
120 | while (fgets (buffer, 1024, stdin) != NULL) | ||
121 | if (!strncmp (buffer, relrec, rellen)) | ||
122 | goto main1; | ||
123 | fatal(); | ||
124 | main1: | ||
125 | sect = malloc(strlen (buffer + rellen) + 1); | ||
126 | if (!sect) fatal(); | ||
127 | strcpy (sect, buffer + rellen); | ||
128 | p = strchr (sect, ']'); | ||
129 | if (!p) fatal(); | ||
130 | *p = 0; | ||
131 | if (fgets (buffer, 1024, stdin) == NULL) | ||
132 | fatal(); | ||
133 | while (fgets (buffer, 1024, stdin) != NULL) { | ||
134 | int nbase; | ||
135 | if (!strncmp (buffer, relrec, rellen)) | ||
136 | goto main1; | ||
137 | if (mode == 0) | ||
138 | set_mode (buffer); | ||
139 | p = strchr (buffer, '\n'); | ||
140 | if (p) *p = 0; | ||
141 | if (strlen (buffer) < 22+mode) | ||
142 | continue; | ||
143 | if (strncmp (buffer + mode, " R_SPARC_", 9)) | ||
144 | continue; | ||
145 | nbase = 27 - 8 + mode; | ||
146 | if (buffer[nbase] != '_' || buffer[nbase+1] != '_' || buffer[nbase+2] != '_') | ||
147 | continue; | ||
148 | switch (buffer[nbase+3]) { | ||
149 | case 'f': /* CALL */ | ||
150 | case 'b': /* BLACKBOX */ | ||
151 | case 's': /* SIMM13 */ | ||
152 | case 'a': /* HALF */ | ||
153 | case 'h': /* SETHI */ | ||
154 | case 'i': /* INT */ | ||
155 | break; | ||
156 | default: | ||
157 | continue; | ||
158 | } | ||
159 | p = strchr (buffer + nbase+5, '+'); | ||
160 | if (p) *p = 0; | ||
161 | shift = nbase + 5; | ||
162 | if (buffer[nbase+4] == 's' && buffer[nbase+5] == '_') { | ||
163 | shift = nbase + 6; | ||
164 | if (strcmp (sect, ".init.text")) { | ||
165 | fprintf(stderr, | ||
166 | "Wrong use of '%s' BTFIXUPSET in '%s' section.\n" | ||
167 | "BTFIXUPSET_CALL can be used only in" | ||
168 | " __init sections\n", | ||
169 | buffer + shift, sect); | ||
170 | exit(1); | ||
171 | } | ||
172 | } else if (buffer[nbase+4] != '_') | ||
173 | continue; | ||
174 | if (!strcmp (sect, ".text.exit")) | ||
175 | continue; | ||
176 | if (strcmp (sect, ".text") && | ||
177 | strcmp (sect, ".init.text") && | ||
178 | strcmp (sect, ".fixup") && | ||
179 | (strcmp (sect, "__ksymtab") || buffer[nbase+3] != 'f')) { | ||
180 | if (buffer[nbase+3] == 'f') | ||
181 | fprintf(stderr, | ||
182 | "Wrong use of '%s' in '%s' section.\n" | ||
183 | " It can be used only in .text, .init.text," | ||
184 | " .fixup and __ksymtab\n", | ||
185 | buffer + shift, sect); | ||
186 | else | ||
187 | fprintf(stderr, | ||
188 | "Wrong use of '%s' in '%s' section.\n" | ||
189 | " It can be only used in .text, .init.text," | ||
190 | " and .fixup\n", buffer + shift, sect); | ||
191 | exit(1); | ||
192 | } | ||
193 | p = strstr (buffer + shift, "__btset_"); | ||
194 | if (p && buffer[nbase+4] == 's') { | ||
195 | fprintf(stderr, "__btset_ in BTFIXUP name can only be used when defining the variable, not for setting\n%s\n", buffer); | ||
196 | exit(1); | ||
197 | } | ||
198 | initval = 0; | ||
199 | initvalstr = NULL; | ||
200 | if (p) { | ||
201 | if (p[8] != '0' || p[9] != 'x') { | ||
202 | fprintf(stderr, "Pre-initialized values can be only initialized with hexadecimal constants starting 0x\n%s\n", buffer); | ||
203 | exit(1); | ||
204 | } | ||
205 | initval = strtoul(p + 10, &q, 16); | ||
206 | if (*q || !initval) { | ||
207 | fprintf(stderr, "Pre-initialized values can be only in the form name__btset_0xXXXXXXXX where X are hex digits.\nThey cannot be name__btset_0x00000000 though. Use BTFIXUPDEF_XX instead of BTFIXUPDEF_XX_INIT then.\n%s\n", buffer); | ||
208 | exit(1); | ||
209 | } | ||
210 | initvalstr = p + 10; | ||
211 | *p = 0; | ||
212 | } | ||
213 | f = find(buffer[nbase+3], buffer + shift); | ||
214 | if (buffer[nbase+4] == 's') | ||
215 | continue; | ||
216 | switch (buffer[nbase+3]) { | ||
217 | case 'f': | ||
218 | if (initval) { | ||
219 | fprintf(stderr, "Cannot use pre-initialized fixups for calls\n%s\n", buffer); | ||
220 | exit(1); | ||
221 | } | ||
222 | if (!strcmp (sect, "__ksymtab")) { | ||
223 | if (strncmp (buffer + mode+9, "32 ", 10)) { | ||
224 | fprintf(stderr, "BTFIXUP_CALL in EXPORT_SYMBOL results in relocation other than R_SPARC_32\n\%s\n", buffer); | ||
225 | exit(1); | ||
226 | } | ||
227 | } else if (strncmp (buffer + mode+9, "WDISP30 ", 10) && | ||
228 | strncmp (buffer + mode+9, "HI22 ", 10) && | ||
229 | strncmp (buffer + mode+9, "LO10 ", 10)) { | ||
230 | fprintf(stderr, "BTFIXUP_CALL results in relocation other than R_SPARC_WDISP30, R_SPARC_HI22 or R_SPARC_LO10\n%s\n", buffer); | ||
231 | exit(1); | ||
232 | } | ||
233 | break; | ||
234 | case 'b': | ||
235 | if (initval) { | ||
236 | fprintf(stderr, "Cannot use pre-initialized fixups for blackboxes\n%s\n", buffer); | ||
237 | exit(1); | ||
238 | } | ||
239 | if (strncmp (buffer + mode+9, "HI22 ", 10)) { | ||
240 | fprintf(stderr, "BTFIXUP_BLACKBOX results in relocation other than R_SPARC_HI22\n%s\n", buffer); | ||
241 | exit(1); | ||
242 | } | ||
243 | break; | ||
244 | case 's': | ||
245 | if (initval + 0x1000 >= 0x2000) { | ||
246 | fprintf(stderr, "Wrong initializer for SIMM13. Has to be from $fffff000 to $00000fff\n%s\n", buffer); | ||
247 | exit(1); | ||
248 | } | ||
249 | if (strncmp (buffer + mode+9, "13 ", 10)) { | ||
250 | fprintf(stderr, "BTFIXUP_SIMM13 results in relocation other than R_SPARC_13\n%s\n", buffer); | ||
251 | exit(1); | ||
252 | } | ||
253 | break; | ||
254 | case 'a': | ||
255 | if (initval + 0x1000 >= 0x2000 && (initval & 0x3ff)) { | ||
256 | fprintf(stderr, "Wrong initializer for HALF.\n%s\n", buffer); | ||
257 | exit(1); | ||
258 | } | ||
259 | if (strncmp (buffer + mode+9, "13 ", 10)) { | ||
260 | fprintf(stderr, "BTFIXUP_HALF results in relocation other than R_SPARC_13\n%s\n", buffer); | ||
261 | exit(1); | ||
262 | } | ||
263 | break; | ||
264 | case 'h': | ||
265 | if (initval & 0x3ff) { | ||
266 | fprintf(stderr, "Wrong initializer for SETHI. Cannot have set low 10 bits\n%s\n", buffer); | ||
267 | exit(1); | ||
268 | } | ||
269 | if (strncmp (buffer + mode+9, "HI22 ", 10)) { | ||
270 | fprintf(stderr, "BTFIXUP_SETHI results in relocation other than R_SPARC_HI22\n%s\n", buffer); | ||
271 | exit(1); | ||
272 | } | ||
273 | break; | ||
274 | case 'i': | ||
275 | if (initval) { | ||
276 | fprintf(stderr, "Cannot use pre-initialized fixups for INT\n%s\n", buffer); | ||
277 | exit(1); | ||
278 | } | ||
279 | if (strncmp (buffer + mode+9, "HI22 ", 10) && strncmp (buffer + mode+9, "LO10 ", 10)) { | ||
280 | fprintf(stderr, "BTFIXUP_INT results in relocation other than R_SPARC_HI22 and R_SPARC_LO10\n%s\n", buffer); | ||
281 | exit(1); | ||
282 | } | ||
283 | break; | ||
284 | } | ||
285 | if (!f->setinitval) { | ||
286 | f->initval = initval; | ||
287 | if (initvalstr) { | ||
288 | f->initvalstr = strdup(initvalstr); | ||
289 | if (!f->initvalstr) fatal(); | ||
290 | } | ||
291 | f->setinitval = 1; | ||
292 | } else if (f->initval != initval) { | ||
293 | fprintf(stderr, "Btfixup %s previously used with initializer %s which doesn't match with current initializer\n%s\n", | ||
294 | f->name, f->initvalstr ? : "0x00000000", buffer); | ||
295 | exit(1); | ||
296 | } else if (initval && strcmp(f->initvalstr, initvalstr)) { | ||
297 | fprintf(stderr, "Btfixup %s previously used with initializer %s which doesn't match with current initializer.\n" | ||
298 | "Initializers have to match literally as well.\n%s\n", | ||
299 | f->name, f->initvalstr, buffer); | ||
300 | exit(1); | ||
301 | } | ||
302 | offset = strtoul(buffer, &q, 16); | ||
303 | if (q != buffer + mode || (!offset && (mode == 8 ? strncmp (buffer, "00000000 ", 9) : strncmp (buffer, "0000000000000000 ", 17)))) { | ||
304 | fprintf(stderr, "Malformed relocation address in\n%s\n", buffer); | ||
305 | exit(1); | ||
306 | } | ||
307 | for (k = 0, r = f->rel, rr = &f->rel; r; rr = &r->next, r = r->next, k++) | ||
308 | if (r->offset == offset && !strcmp(r->sect, sect)) { | ||
309 | fprintf(stderr, "Ugh. One address has two relocation records\n"); | ||
310 | exit(1); | ||
311 | } | ||
312 | *rr = malloc(sizeof(btfixuprel)); | ||
313 | if (!*rr) fatal(); | ||
314 | (*rr)->offset = offset; | ||
315 | (*rr)->f = NULL; | ||
316 | if (buffer[nbase+3] == 'f') { | ||
317 | lastf = f; | ||
318 | lastfoffset = offset; | ||
319 | lastfrelno = k; | ||
320 | } else if (lastfoffset + 4 == offset) { | ||
321 | (*rr)->f = lastf; | ||
322 | (*rr)->frel = lastfrelno; | ||
323 | } | ||
324 | (*rr)->sect = sect; | ||
325 | (*rr)->next = NULL; | ||
326 | } | ||
327 | printf("! Generated by btfixupprep. Do not edit.\n\n"); | ||
328 | printf("\t.section\t\".data..init\",#alloc,#write\n\t.align\t4\n\n"); | ||
329 | printf("\t.global\t___btfixup_start\n___btfixup_start:\n\n"); | ||
330 | for (i = 0; i < last; i++) { | ||
331 | f = array + i; | ||
332 | printf("\t.global\t___%cs_%s\n", f->type, f->name); | ||
333 | if (f->type == 'f') | ||
334 | printf("___%cs_%s:\n\t.word 0x%08x,0,0,", f->type, f->name, f->type << 24); | ||
335 | else | ||
336 | printf("___%cs_%s:\n\t.word 0x%08x,0,", f->type, f->name, f->type << 24); | ||
337 | for (j = 0, r = f->rel; r != NULL; j++, r = r->next); | ||
338 | if (j) | ||
339 | printf("%d\n\t.word\t", j * 2); | ||
340 | else | ||
341 | printf("0\n"); | ||
342 | for (r = f->rel, j--; r != NULL; j--, r = r->next) { | ||
343 | if (!strcmp (r->sect, ".text")) | ||
344 | printf ("_stext+0x%08lx", r->offset); | ||
345 | else if (!strcmp (r->sect, ".init.text")) | ||
346 | printf ("__init_begin+0x%08lx", r->offset); | ||
347 | else if (!strcmp (r->sect, "__ksymtab")) | ||
348 | printf ("__start___ksymtab+0x%08lx", r->offset); | ||
349 | else if (!strcmp (r->sect, ".fixup")) | ||
350 | printf ("__start___fixup+0x%08lx", r->offset); | ||
351 | else | ||
352 | fatal(); | ||
353 | if (f->type == 'f' || !r->f) | ||
354 | printf (",0"); | ||
355 | else | ||
356 | printf (",___fs_%s+0x%08x", r->f->name, (4 + r->frel*2)*4 + 4); | ||
357 | if (j) printf (","); | ||
358 | else printf ("\n"); | ||
359 | } | ||
360 | printf("\n"); | ||
361 | } | ||
362 | printf("\n\t.global\t___btfixup_end\n___btfixup_end:\n"); | ||
363 | printf("\n\n! Define undefined references\n\n"); | ||
364 | for (i = 0; i < last; i++) { | ||
365 | f = array + i; | ||
366 | if (f->type == 'f') { | ||
367 | printf("\t.global\t___f_%s\n", f->name); | ||
368 | printf("___f_%s:\n", f->name); | ||
369 | } | ||
370 | } | ||
371 | printf("\tretl\n\t nop\n\n"); | ||
372 | for (i = 0; i < last; i++) { | ||
373 | f = array + i; | ||
374 | if (f->type != 'f') { | ||
375 | if (!f->initval) { | ||
376 | printf("\t.global\t___%c_%s\n", f->type, f->name); | ||
377 | printf("___%c_%s = 0\n", f->type, f->name); | ||
378 | } else { | ||
379 | printf("\t.global\t___%c_%s__btset_0x%s\n", f->type, f->name, f->initvalstr); | ||
380 | printf("___%c_%s__btset_0x%s = 0x%08x\n", f->type, f->name, f->initvalstr, f->initval); | ||
381 | } | ||
382 | } | ||
383 | } | ||
384 | printf("\n\n"); | ||
385 | exit(0); | ||
386 | } | ||