avr-gcc, attiny2313a und __eerd_byte_tn2313a nicht linkbar.

OP #3223259
Lesenswert?

Moin,

ich habe hier ein kleines Problem, entweder aus dem WinAVR-Makefile oder 
anderswoher, er findet beim linken wohl keinen Weg das EEPROM zu lesen 
(bzw die Funktion dazu). Ich habe versucht das ganze mal so minimal wie 
möglich nachzubauen, daher auch keine Main-Loop etc:

Kleine Testdatei main.c:
1
#include <avr/eeprom.h>
2

3
uint8_t EEMEM eep_interval = 3;
4
static volatile uint8_t isr_interval;
5

6
int main (void) {
7
    uint8_t interval; 
8
    interval = eeprom_read_byte(&eep_interval); 
9
    isr_interval = interval;
10
}
1
> avr-gcc -c -mmcu=attiny2313a -I. -gdwarf-2 -DF_CPU=8000000UL -Os -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums -ffunction-sections -fdata-sections -Wall -Wstrict-prototypes -Wa,-adhlns=./main.lst -I../lib/ -std=gnu99 -Wundef -MMD -MP -MF .dep/main.o.d main.c -o main.o  
2

3
> avr-gcc -mmcu=attiny2313a -I. -gdwarf-2 -DF_CPU=8000000UL -Os -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums -ffunction-sections -fdata-sections -Wall -Wstrict-prototypes -Wa,-adhlns=main.o -I../lib/ -std=gnu99 -Wundef -MMD -MP -MF .dep/main.elf.d main.o --output main.elf -Wl,-Map=main.map,--cref -lm -Wl,--gc-sections    
4
main.o: In function `main':
5
/tmp/test/main.c:8: undefined reference to `__eerd_byte_tn2313a'
6
collect2: error: ld returned 1 exit status
7

8
> cat main.map
9
Archive member included because of file (symbol)
10

11
/usr/lib/gcc/avr/4.7.2/avr25/tiny-stack/libgcc.a(_exit.o)
12
                              /usr/lib/gcc/avr/4.7.2/../../../avr/lib/crttn2313a.o (exit)
13
/usr/lib/gcc/avr/4.7.2/avr25/tiny-stack/libgcc.a(_clear_bss.o)
14
                              main.o (__do_clear_bss)
15

16
Discarded input sections
17

18
 .data          0x0000000000000000        0x0 /usr/lib/gcc/avr/4.7.2/../../../avr/lib/crttn2313a.o
19
 .bss           0x0000000000000000        0x0 /usr/lib/gcc/avr/4.7.2/../../../avr/lib/crttn2313a.o
20
 .text          0x0000000000000000        0x0 main.o
21
 .data          0x0000000000000000        0x0 main.o
22
 .bss           0x0000000000000000        0x0 main.o
23
 .text          0x0000000000000000        0x0 /usr/lib/gcc/avr/4.7.2/avr25/tiny-stack/libgcc.a(_exit.o)
24
 .data          0x0000000000000000        0x0 /usr/lib/gcc/avr/4.7.2/avr25/tiny-stack/libgcc.a(_exit.o)
25
 .bss           0x0000000000000000        0x0 /usr/lib/gcc/avr/4.7.2/avr25/tiny-stack/libgcc.a(_exit.o)
26
 .text.libgcc.mul
27
                0x0000000000000000        0x0 /usr/lib/gcc/avr/4.7.2/avr25/tiny-stack/libgcc.a(_exit.o)
28
 .text.libgcc.div
29
                0x0000000000000000        0x0 /usr/lib/gcc/avr/4.7.2/avr25/tiny-stack/libgcc.a(_exit.o)
30
 .text.libgcc   0x0000000000000000        0x0 /usr/lib/gcc/avr/4.7.2/avr25/tiny-stack/libgcc.a(_exit.o)
31
 .text.libgcc.prologue
32
                0x0000000000000000        0x0 /usr/lib/gcc/avr/4.7.2/avr25/tiny-stack/libgcc.a(_exit.o)
33
 .text.libgcc.builtins
34
                0x0000000000000000        0x0 /usr/lib/gcc/avr/4.7.2/avr25/tiny-stack/libgcc.a(_exit.o)
35
 .text.libgcc.fmul
36
                0x0000000000000000        0x0 /usr/lib/gcc/avr/4.7.2/avr25/tiny-stack/libgcc.a(_exit.o)
37
 .text          0x0000000000000000        0x0 /usr/lib/gcc/avr/4.7.2/avr25/tiny-stack/libgcc.a(_clear_bss.o)
38
 .data          0x0000000000000000        0x0 /usr/lib/gcc/avr/4.7.2/avr25/tiny-stack/libgcc.a(_clear_bss.o)
39
 .bss           0x0000000000000000        0x0 /usr/lib/gcc/avr/4.7.2/avr25/tiny-stack/libgcc.a(_clear_bss.o)
40
 .text.libgcc.mul
41
                0x0000000000000000        0x0 /usr/lib/gcc/avr/4.7.2/avr25/tiny-stack/libgcc.a(_clear_bss.o)
42
 .text.libgcc.div
43
                0x0000000000000000        0x0 /usr/lib/gcc/avr/4.7.2/avr25/tiny-stack/libgcc.a(_clear_bss.o)
44
 .text.libgcc   0x0000000000000000        0x0 /usr/lib/gcc/avr/4.7.2/avr25/tiny-stack/libgcc.a(_clear_bss.o)
45
 .text.libgcc.prologue
46
                0x0000000000000000        0x0 /usr/lib/gcc/avr/4.7.2/avr25/tiny-stack/libgcc.a(_clear_bss.o)
47
 .text.libgcc.builtins
48
                0x0000000000000000        0x0 /usr/lib/gcc/avr/4.7.2/avr25/tiny-stack/libgcc.a(_clear_bss.o)
49
 .text.libgcc.fmul
50
                0x0000000000000000        0x0 /usr/lib/gcc/avr/4.7.2/avr25/tiny-stack/libgcc.a(_clear_bss.o)
51

52
Memory Configuration
53

54
Name             Origin             Length             Attributes
55
text             0x0000000000000000 0x0000000000002000 xr
56
data             0x0000000000800060 0x000000000000ffa0 rw !x
57
eeprom           0x0000000000810000 0x0000000000010000 rw !x
58
fuse             0x0000000000820000 0x0000000000000400 rw !x
59
lock             0x0000000000830000 0x0000000000000400 rw !x
60
signature        0x0000000000840000 0x0000000000000400 rw !x
61
*default*        0x0000000000000000 0xffffffffffffffff
62

63
Linker script and memory map
64

65
LOAD /usr/lib/gcc/avr/4.7.2/../../../avr/lib/crttn2313a.o
66
LOAD main.o
67
LOAD /usr/lib/gcc/avr/4.7.2/../../../avr/lib/libm.a
68
LOAD /usr/lib/gcc/avr/4.7.2/avr25/tiny-stack/libgcc.a
69
LOAD /usr/lib/gcc/avr/4.7.2/../../../avr/lib/libc.a
70
LOAD /usr/lib/gcc/avr/4.7.2/avr25/tiny-stack/libgcc.a
71

72
.hash
73
 *(.hash)
74

75
.dynsym
76
 *(.dynsym)
77

78
.dynstr
79
 *(.dynstr)
80

81
.gnu.version
82
 *(.gnu.version)
83

84
.gnu.version_d
85
 *(.gnu.version_d)
86

87
.gnu.version_r
88
 *(.gnu.version_r)
89

90
.rel.init
91
 *(.rel.init)
92

93
.rela.init
94
 *(.rela.init)
95

96
.rel.text
97
 *(.rel.text)
98
 *(.rel.text.*)
99
 *(.rel.gnu.linkonce.t*)
100

101
.rela.text
102
 *(.rela.text)
103
 *(.rela.text.*)
104
 *(.rela.gnu.linkonce.t*)
105

106
.rel.fini
107
 *(.rel.fini)
108

109
.rela.fini
110
 *(.rela.fini)
111

112
.rel.rodata
113
 *(.rel.rodata)
114
 *(.rel.rodata.*)
115
 *(.rel.gnu.linkonce.r*)
116

117
.rela.rodata
118
 *(.rela.rodata)
119
 *(.rela.rodata.*)
120
 *(.rela.gnu.linkonce.r*)
121

122
.rel.data
123
 *(.rel.data)
124
 *(.rel.data.*)
125
 *(.rel.gnu.linkonce.d*)
126

127
.rela.data
128
 *(.rela.data)
129
 *(.rela.data.*)
130
 *(.rela.gnu.linkonce.d*)
131

132
.rel.ctors
133
 *(.rel.ctors)
134

135
.rela.ctors
136
 *(.rela.ctors)
137

138
.rel.dtors
139
 *(.rel.dtors)
140

141
.rela.dtors
142
 *(.rela.dtors)
143

144
.rel.got
145
 *(.rel.got)
146

147
.rela.got
148
 *(.rela.got)
149

150
.rel.bss
151
 *(.rel.bss)
152

153
.rela.bss
154
 *(.rela.bss)
155

156
.rel.plt
157
 *(.rel.plt)
158

159
.rela.plt
160
 *(.rela.plt)
161

162
.text           0x0000000000000000       0x5c
163
 *(.vectors)
164
 .vectors       0x0000000000000000       0x2a /usr/lib/gcc/avr/4.7.2/../../../avr/lib/crttn2313a.o
165
                0x0000000000000000                __vectors
166
                0x0000000000000000                __vector_default
167
 *(.vectors)
168
 *(.progmem.gcc*)
169
 *(.progmem*)
170
                0x000000000000002a                . = ALIGN (0x2)
171
                0x000000000000002a                __trampolines_start = .
172
 *(.trampolines)
173
 .trampolines   0x000000000000002a        0x0 linker stubs
174
 *(.trampolines*)
175
                0x000000000000002a                __trampolines_end = .
176
 *(.jumptables)
177
 *(.jumptables*)
178
 *(.lowtext)
179
 *(.lowtext*)
180
                0x000000000000002a                __ctors_start = .
181
 *(.ctors)
182
                0x000000000000002a                __ctors_end = .
183
                0x000000000000002a                __dtors_start = .
184
 *(.dtors)
185
                0x000000000000002a                __dtors_end = .
186
 SORT(*)(.ctors)
187
 SORT(*)(.dtors)
188
 *(.init0)
189
 .init0         0x000000000000002a        0x0 /usr/lib/gcc/avr/4.7.2/../../../avr/lib/crttn2313a.o
190
                0x000000000000002a                __init
191
 *(.init0)
192
 *(.init1)
193
 *(.init1)
194
 *(.init2)
195
 .init2         0x000000000000002a        0x8 /usr/lib/gcc/avr/4.7.2/../../../avr/lib/crttn2313a.o
196
 *(.init2)
197
 *(.init3)
198
 *(.init3)
199
 *(.init4)
200
 .init4         0x0000000000000032       0x10 /usr/lib/gcc/avr/4.7.2/avr25/tiny-stack/libgcc.a(_clear_bss.o)
201
                0x0000000000000032                __do_clear_bss
202
 *(.init4)
203
 *(.init5)
204
 *(.init5)
205
 *(.init6)
206
 *(.init6)
207
 *(.init7)
208
 *(.init7)
209
 *(.init8)
210
 *(.init8)
211
 *(.init9)
212
 .init9         0x0000000000000042        0x4 /usr/lib/gcc/avr/4.7.2/../../../avr/lib/crttn2313a.o
213
 *(.init9)
214
 *(.text)
215
 .text          0x0000000000000046        0x2 /usr/lib/gcc/avr/4.7.2/../../../avr/lib/crttn2313a.o
216
                0x0000000000000046                __vector_1
217
                0x0000000000000046                __vector_12
218
                0x0000000000000046                __bad_interrupt
219
                0x0000000000000046                __vector_6
220
                0x0000000000000046                __vector_3
221
                0x0000000000000046                __vector_11
222
                0x0000000000000046                __vector_13
223
                0x0000000000000046                __vector_17
224
                0x0000000000000046                __vector_19
225
                0x0000000000000046                __vector_7
226
                0x0000000000000046                __vector_5
227
                0x0000000000000046                __vector_4
228
                0x0000000000000046                __vector_9
229
                0x0000000000000046                __vector_2
230
                0x0000000000000046                __vector_15
231
                0x0000000000000046                __vector_8
232
                0x0000000000000046                __vector_14
233
                0x0000000000000046                __vector_10
234
                0x0000000000000046                __vector_16
235
                0x0000000000000046                __vector_18
236
                0x0000000000000046                __vector_20
237
                0x0000000000000048                . = ALIGN (0x2)
238
 *(.text.*)
239
 .text.startup.main
240
                0x0000000000000048       0x10 main.o
241
                0x0000000000000048                main
242
                0x0000000000000058                . = ALIGN (0x2)
243
 *(.fini9)
244
 .fini9         0x0000000000000058        0x0 /usr/lib/gcc/avr/4.7.2/avr25/tiny-stack/libgcc.a(_exit.o)
245
                0x0000000000000058                exit
246
                0x0000000000000058                _exit
247
 *(.fini9)
248
 *(.fini8)
249
 *(.fini8)
250
 *(.fini7)
251
 *(.fini7)
252
 *(.fini6)
253
 *(.fini6)
254
 *(.fini5)
255
 *(.fini5)
256
 *(.fini4)
257
 *(.fini4)
258
 *(.fini3)
259
 *(.fini3)
260
 *(.fini2)
261
 *(.fini2)
262
 *(.fini1)
263
 *(.fini1)
264
 *(.fini0)
265
 .fini0         0x0000000000000058        0x4 /usr/lib/gcc/avr/4.7.2/avr25/tiny-stack/libgcc.a(_exit.o)
266
 *(.fini0)
267
                0x000000000000005c                _etext = .
268

269
.data           0x0000000000800060        0x0 load address 0x000000000000005c
270
                0x0000000000800060                PROVIDE (__data_start, .)
271
 *(.data)
272
 *(.data*)
273
 *(.rodata)
274
 *(.rodata*)
275
 *(.gnu.linkonce.d*)
276
                0x0000000000800060                . = ALIGN (0x2)
277
                0x0000000000800060                _edata = .
278
                0x0000000000800060                PROVIDE (__data_end, .)
279

280
.bss            0x0000000000800060        0x1
281
                0x0000000000800060                PROVIDE (__bss_start, .)
282
 *(.bss)
283
 *(.bss*)
284
 .bss.isr_interval
285
                0x0000000000800060        0x1 main.o
286
 *(COMMON)
287
                0x0000000000800061                PROVIDE (__bss_end, .)
288
                0x000000000000005c                __data_load_start = LOADADDR (.data)
289
                0x000000000000005c                __data_load_end = (__data_load_start + SIZEOF (.data))
290

291
.noinit         0x0000000000800061        0x0
292
                0x0000000000800061                PROVIDE (__noinit_start, .)
293
 *(.noinit*)
294
                0x0000000000800061                PROVIDE (__noinit_end, .)
295
                0x0000000000800061                _end = .
296
                0x0000000000800061                PROVIDE (__heap_start, .)
297

298
.eeprom         0x0000000000810000        0x1
299
 *(.eeprom*)
300
 .eeprom        0x0000000000810000        0x1 main.o
301
                0x0000000000810000                eep_interval
302
                0x0000000000810001                __eeprom_end = .
303

304
.fuse
305
 *(.fuse)
306
 *(.lfuse)
307
 *(.hfuse)
308
 *(.efuse)
309

310
.lock
311
 *(.lock*)
312

313
.signature
314
 *(.signature*)
315

316
.stab           0x0000000000000000      0x6b4
317
 *(.stab)
318
 .stab          0x0000000000000000      0x6b4 /usr/lib/gcc/avr/4.7.2/../../../avr/lib/crttn2313a.o
319

320
.stabstr        0x0000000000000000       0x54
321
 *(.stabstr)
322
 .stabstr       0x0000000000000000       0x54 /usr/lib/gcc/avr/4.7.2/../../../avr/lib/crttn2313a.o
323

324
.stab.excl
325
 *(.stab.excl)
326

327
.stab.exclstr
328
 *(.stab.exclstr)
329

330
.stab.index
331
 *(.stab.index)
332

333
.stab.indexstr
334
 *(.stab.indexstr)
335

336
.comment        0x0000000000000000       0x11
337
 *(.comment)
338
 .comment       0x0000000000000000       0x11 main.o
339
                                         0x12 (size before relaxing)
340

341
.debug
342
 *(.debug)
343

344
.line
345
 *(.line)
346

347
.debug_srcinfo
348
 *(.debug_srcinfo)
349

350
.debug_sfnames
351
 *(.debug_sfnames)
352

353
.debug_aranges  0x0000000000000000       0x20
354
 *(.debug_aranges)
355
 .debug_aranges
356
                0x0000000000000000       0x20 main.o
357

358
.debug_pubnames
359
 *(.debug_pubnames)
360

361
.debug_info     0x0000000000000000       0xff
362
 *(.debug_info)
363
 .debug_info    0x0000000000000000       0xff main.o
364
 *(.gnu.linkonce.wi.*)
365

366
.debug_abbrev   0x0000000000000000       0xce
367
 *(.debug_abbrev)
368
 .debug_abbrev  0x0000000000000000       0xce main.o
369

370
.debug_line     0x0000000000000000       0xa8
371
 *(.debug_line)
372
 .debug_line    0x0000000000000000       0xa8 main.o
373

374
.debug_frame    0x0000000000000000       0x24
375
 *(.debug_frame)
376
 .debug_frame   0x0000000000000000       0x24 main.o
377

378
.debug_str      0x0000000000000000       0x8b
379
 *(.debug_str)
380
 .debug_str     0x0000000000000000       0x8b main.o
381
                                         0xc8 (size before relaxing)
382

383
.debug_loc      0x0000000000000000       0x22
384
 *(.debug_loc)
385
 .debug_loc     0x0000000000000000       0x22 main.o
386

387
.debug_macinfo
388
 *(.debug_macinfo)
389
OUTPUT(main.elf elf32-avr)
390
LOAD linker stubs
391

392
.debug_ranges   0x0000000000000000       0x10
393
 .debug_ranges  0x0000000000000000       0x10 main.o
394

395
Cross Reference Table
396

397
Symbol                                            File
398
__bad_interrupt                                   /usr/lib/gcc/avr/4.7.2/../../../avr/lib/crttn2313a.o
399
__bss_end                                         /usr/lib/gcc/avr/4.7.2/avr25/tiny-stack/libgcc.a(_clear_bss.o)
400
__bss_start                                       /usr/lib/gcc/avr/4.7.2/avr25/tiny-stack/libgcc.a(_clear_bss.o)
401
__do_clear_bss                                    /usr/lib/gcc/avr/4.7.2/avr25/tiny-stack/libgcc.a(_clear_bss.o)
402
                                                  main.o
403
__eerd_byte_tn2313a                               main.o
404
__heap_end                                        /usr/lib/gcc/avr/4.7.2/../../../avr/lib/crttn2313a.o
405
__init                                            /usr/lib/gcc/avr/4.7.2/../../../avr/lib/crttn2313a.o
406
__stack                                           /usr/lib/gcc/avr/4.7.2/../../../avr/lib/crttn2313a.o
407
__vector_1                                        /usr/lib/gcc/avr/4.7.2/../../../avr/lib/crttn2313a.o
408
__vector_10                                       /usr/lib/gcc/avr/4.7.2/../../../avr/lib/crttn2313a.o
409
__vector_11                                       /usr/lib/gcc/avr/4.7.2/../../../avr/lib/crttn2313a.o
410
__vector_12                                       /usr/lib/gcc/avr/4.7.2/../../../avr/lib/crttn2313a.o
411
__vector_13                                       /usr/lib/gcc/avr/4.7.2/../../../avr/lib/crttn2313a.o
412
__vector_14                                       /usr/lib/gcc/avr/4.7.2/../../../avr/lib/crttn2313a.o
413
__vector_15                                       /usr/lib/gcc/avr/4.7.2/../../../avr/lib/crttn2313a.o
414
__vector_16                                       /usr/lib/gcc/avr/4.7.2/../../../avr/lib/crttn2313a.o
415
__vector_17                                       /usr/lib/gcc/avr/4.7.2/../../../avr/lib/crttn2313a.o
416
__vector_18                                       /usr/lib/gcc/avr/4.7.2/../../../avr/lib/crttn2313a.o
417
__vector_19                                       /usr/lib/gcc/avr/4.7.2/../../../avr/lib/crttn2313a.o
418
__vector_2                                        /usr/lib/gcc/avr/4.7.2/../../../avr/lib/crttn2313a.o
419
__vector_20                                       /usr/lib/gcc/avr/4.7.2/../../../avr/lib/crttn2313a.o
420
__vector_3                                        /usr/lib/gcc/avr/4.7.2/../../../avr/lib/crttn2313a.o
421
__vector_4                                        /usr/lib/gcc/avr/4.7.2/../../../avr/lib/crttn2313a.o
422
__vector_5                                        /usr/lib/gcc/avr/4.7.2/../../../avr/lib/crttn2313a.o
423
__vector_6                                        /usr/lib/gcc/avr/4.7.2/../../../avr/lib/crttn2313a.o
424
__vector_7                                        /usr/lib/gcc/avr/4.7.2/../../../avr/lib/crttn2313a.o
425
__vector_8                                        /usr/lib/gcc/avr/4.7.2/../../../avr/lib/crttn2313a.o
426
__vector_9                                        /usr/lib/gcc/avr/4.7.2/../../../avr/lib/crttn2313a.o
427
__vector_default                                  /usr/lib/gcc/avr/4.7.2/../../../avr/lib/crttn2313a.o
428
__vectors                                         /usr/lib/gcc/avr/4.7.2/../../../avr/lib/crttn2313a.o
429
_exit                                             /usr/lib/gcc/avr/4.7.2/avr25/tiny-stack/libgcc.a(_exit.o)
430
eep_interval                                      main.o
431
exit                                              /usr/lib/gcc/avr/4.7.2/avr25/tiny-stack/libgcc.a(_exit.o)
432
                                                  /usr/lib/gcc/avr/4.7.2/../../../avr/lib/crttn2313a.o
433
main                                              main.o
434
                                                  /usr/lib/gcc/avr/4.7.2/../../../avr/lib/crttn2313a.o

Hat jemand eine Idee, welche Einstellung oder sonstiges Problem hierzu 
führt?

Danke
Moritz
OP #3223317
Lesenswert?

Was ich dir bieten kann ist:
1
> ls /usr/lib/avr/lib/avr25/
2
crt86401.o    crttn24.o    crttn44.o    crttn85.o    libprintf_flt.a
3
crta6289.o    crttn25.o    crttn45.o    crttn861a.o  libprintf_min.a
4
crttn13a.o    crttn261a.o  crttn461a.o  crttn861.o   libscanf_flt.a
5
crttn13.o     crttn261.o   crttn461.o   crttn87.o    libscanf_min.a
6
crttn2313a.o  crttn4313.o  crttn48.o    crttn88.o
7
crttn2313.o   crttn43u.o   crttn84a.o   libc.a
8
crttn24a.o    crttn44a.o   crttn84.o    libm.a

Das ganze ist ein debian testing/sid,
1
avr-libc:
2
  Installed: 1:1.8.0-2
3
gcc-avr:
4
  Installed: 1:4.7.2-2

Aber ich habe im Upstream-Bugreport den Workaround gefunden, avr25/ nach 
avr25/tiny-stack zu kopieren, damit tut es (erstmal).

Danke
Persönliche Seite #3223345
Lesenswert?

Moritz A. schrieb:
> Johann L. schrieb:
>> Ok, da hat wohl jemand das Kleingedruckte nicht gelesen.
>
> Was auch immer du damit sagen möchtest.

Daß man, wenn man eine Toolchain aus den Quellen erzeugt, die Release 
Notes lesen und beachten sollte — zumal wenn man eine Distribution 
erstellt um diese unters gemeine Volk zu bringen.

Teilweise werden Schalter gesetzt, die vor 10 Jahren genraucht wurden, 
aber um die heute relevanten Feinheiten kümmert sich niemand...

Antwort schreiben

Bitte melde dich an, um einen Beitrag zu schreiben.

oder

Mit Google-Account einloggen

Die Registrierung ist kostenlos und dauert nur eine Minute.

Jetzt registrieren