This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Use .init_array, .fini_array sections for ARM EABI(broke -target=avr)


> From: "Joseph S. Myers" <joseph@codesourcery.com>
>> On Sat, 30 Apr 2005, Daniel Jacobowitz wrote:
>>> The definition/use of __main is now dependant on INIT_ARRAY_SECTION_ASM_OP
>>> HAS_INIT_SECTION , and .init_array, resulting in __main not being defined as
>>> presumed by the avr when linking; and may possibly affect other things but
>>> haven't gotten that far yet.
>>> 
>>> (a fix may be as simple as defining HAS_INIT_SECTION in libgcc2.c
>>>  regardless of INIT_ARRAY_SECTION_ASM_OP, but not really sure?)
>> 
>> You're going to have to provide more details, since I can't see how the
>> patch could cause the problem you're describing.
>> 
>> Error messages, preprocessed source, and all the other sorts of details
>> that a bug report normally requires, please.
> 
> Bootstrap on hppa2.0w-hpux fails today with:
> 
> stage1/xgcc -Bstage1/
> -B/scratch/gcc/nightly-2005-04-30-mainline/hppa2.0w-hp-hpux11.11/build_gcc/ins
> tall/hppa2.0w-hp-hpux11.11/bin/
> -g -O2 -DIN_GCC   -W -Wall -Wwrite-strings -Wstrict-prototypes
> -Wmissing-prototypes -pedantic -Wno-long-long -Wno-variadic-macros
> -Wold-style-definition -Werror -fno-common   -DHAVE_CONFIG_H
> -DGENERATOR_FILE  -o build/genmodes \
>  build/genmodes.o build/errors.o
> ../build-hppa2.0w-hp-hpux11.11/libiberty/libiberty.a
> /usr/ccs/bin/ld: Unsatisfied symbols:
>    __main (first referenced in build/genmodes.o) (code)
> collect2: ld returned 1 exit status
> make[2]: *** [build/genmodes] Error 1
> 
> This may or may not relate to the quoted garbled description of symptoms
> on avr; I haven't yet investigated it further.

Yup, that was much clearer than stating that __main was not being defined as
expected when linking (so if preferred):

Linking: main.elf
avr-gcc -mmcu=atmega64 -I. -g   -Os -funsigned-char -funsigned-bitfields
-fpack-struct -fshort-enums -Wall -Wstrict-prototypes -Wa,-adhlns=main.o
-fdump-tree-all -da -I/usr/local/avr/include -std=gnu99
-funsafe-math-optimizations -Wp,-M,-MP,-MT,main.o,-MF,.dep/main.elf.d main.o
--output main.elf -Wl,-Map=main.map,--cref    -lm
main.o: In function `main':
/Applications/avr/tests/test/main.c:18: undefined reference to `__main'
make: *** [main.elf] Error 1

---

main.lst:

   1                       .file    "main.c"
   2                       .arch atmega64
   3                   __SREG__ = 0x3f
   4                   __SP_H__ = 0x3e
   5                   __SP_L__ = 0x3d
   6                   __tmp_reg__ = 0
   7                   __zero_reg__ = 1
   8                       .global __do_copy_data
   9                       .global __do_clear_bss
  12                       .text
  13                   .Ltext0:
  30                       .data
  31                   .LC0:
  32 0000 6162 6364         .string    "abcde"
  32      6500 
  33                       .text
  35                   .global    foo
  37                   foo:
  38                       .stabd    46,0,0
   1:main.c        **** volatile char v;
   2:main.c        ****
   3:main.c        **** void foo ( void )
   4:main.c        **** {
  40                   .LM0:
  41                   /* prologue: frame size=5 */
  42 0000 CF93              push r28
  43 0002 DF93              push r29
  44 0004 CDB7              in r28,__SP_L__
  45 0006 DEB7              in r29,__SP_H__
  46 0008 2597              sbiw r28,5
  47 000a 0FB6              in __tmp_reg__,__SREG__
  48 000c F894              cli
  49 000e DEBF              out __SP_H__,r29
  50 0010 0FBE              out __SREG__,__tmp_reg__
  51 0012 CDBF              out __SP_L__,r28
  52                   /* prologue end (size=10) */
   5:main.c        ****   char x[5] = {"abcde"};
  54                   .LM1:
  55 0014 DE01              movw r26,r28
  56 0016 1196              adiw r26,1
  57 0018 E0E0              ldi r30,lo8(.LC0)
  58 001a F0E0              ldi r31,hi8(.LC0)
  59 001c 85E0              ldi r24,lo8(5)
  60                   .L2:
  62                   .LM2:
  63 001e 0190              ld r0,Z+
  64 0020 0D92              st X+,r0
  65 0022 8150              subi r24,lo8(-(-1))
  66 0024 E1F7              brne .L2
   6:main.c        ****
   7:main.c        ****   v = x[v];
  68                   .LM3:
  69 0026 8091 0000         lds r24,v
  70 002a FE01              movw r30,r28
  71 002c E80F              add r30,r24
  72 002e F11D              adc r31,__zero_reg__
  73 0030 8181              ldd r24,Z+1
  74 0032 8093 0000         sts v,r24
  75                   /* epilogue: frame size=5 */
  76 0036 2596              adiw r28,5
  77 0038 0FB6              in __tmp_reg__,__SREG__
  78 003a F894              cli
  79 003c DEBF              out __SP_H__,r29
  80 003e 0FBE              out __SREG__,__tmp_reg__
  81 0040 CDBF              out __SP_L__,r28
  82 0042 DF91              pop r29
  83 0044 CF91              pop r28
  84 0046 0895              ret
  85                   /* epilogue end (size=9) */
  86                   /* function foo size 37 (18) */
  91                   .Lscope0:
  93                       .stabd    78,0,0
  94                       .data
  97                   C.1.1222:
  98 0006 61                .byte    97
  99 0007 62                .byte    98
 100 0008 63                .byte    99
 101 0009 64                .byte    100
 102 000a 65                .byte    101
 103                       .text
 105                   .global    bar
 107                   bar:
 108                       .stabd    46,0,0
   8:main.c        **** }
   9:main.c        ****
  10:main.c        **** void bar ( void )
  11:main.c        **** {
 110                   .LM4:
 111                   /* prologue: frame size=5 */
 112 0048 CF93              push r28
 113 004a DF93              push r29
 114 004c CDB7              in r28,__SP_L__
 115 004e DEB7              in r29,__SP_H__
 116 0050 2597              sbiw r28,5
 117 0052 0FB6              in __tmp_reg__,__SREG__
 118 0054 F894              cli
 119 0056 DEBF              out __SP_H__,r29
 120 0058 0FBE              out __SREG__,__tmp_reg__
 121 005a CDBF              out __SP_L__,r28
 122                   /* prologue end (size=10) */
  12:main.c        ****   char y[5] = {'a','b','c','d','e'};
 124                   .LM5:
 125 005c DE01              movw r26,r28
 126 005e 1196              adiw r26,1
 127 0060 E0E0              ldi r30,lo8(C.1.1222)
 128 0062 F0E0              ldi r31,hi8(C.1.1222)
 129 0064 85E0              ldi r24,lo8(5)
 130                   .L7:
 132                   .LM6:
 133 0066 0490              lpm r0,Z
 134 0068 0D92              st X+,r0
 135 006a 8150              subi r24,lo8(-(-1))
 136 006c E1F7              brne .L7
  13:main.c        ****
  14:main.c        ****   v = y[v];
 138                   .LM7:
 139 006e 8091 0000         lds r24,v
 140 0072 FE01              movw r30,r28
 141 0074 E80F              add r30,r24
 142 0076 F11D              adc r31,__zero_reg__
 143 0078 8181              ldd r24,Z+1
 144 007a 8093 0000         sts v,r24
 145                   /* epilogue: frame size=5 */
 146 007e 2596              adiw r28,5
 147 0080 0FB6              in __tmp_reg__,__SREG__
 148 0082 F894              cli
 149 0084 DEBF              out __SP_H__,r29
 150 0086 0FBE              out __SREG__,__tmp_reg__
 151 0088 CDBF              out __SP_L__,r28
 152 008a DF91              pop r29
 153 008c CF91              pop r28
 154 008e 0895              ret
 155                   /* epilogue end (size=9) */
 156                   /* function bar size 37 (18) */
 161                   .Lscope1:
 163                       .stabd    78,0,0
 164                       .data
 167                   C.3.1233:
 168 000b 61                .byte    97
 169 000c 62                .byte    98
 170 000d 63                .byte    99
 171 000e 64                .byte    100
 172 000f 65                .byte    101
 173                       .text
 175                   .global    main
 177                   main:
 178                       .stabd    46,0,0
  15:main.c        **** }
  16:main.c        ****
  17:main.c        **** int main ( void )
  18:main.c        **** {
 180                   .LM8:
 181                   /* prologue: frame size=17 */
 182 0090 C0E0              ldi r28,lo8(__stack - 17)
 183 0092 D0E0              ldi r29,hi8(__stack - 17)
 184 0094 DEBF              out __SP_H__,r29
 185 0096 CDBF              out __SP_L__,r28
 186                   /* prologue end (size=4) */
 187 0098 0E94 0000         call __main
  19:main.c        ****   char x[5] = {"abcde"}; // Initializer string not
marked READONLY static const.
 189                   .LM9:
 190 009c DE01              movw r26,r28
 191 009e 1396              adiw r26,3
 192 00a0 E0E0              ldi r30,lo8(.LC0)
 193 00a2 F0E0              ldi r31,hi8(.LC0)
 194 00a4 85E0              ldi r24,lo8(5)
 195                   .L12:
 197                   .LM10:
 198 00a6 0190              ld r0,Z+
 199 00a8 0D92              st X+,r0
 200 00aa 8150              subi r24,lo8(-(-1))
 201 00ac E1F7              brne .L12
  20:main.c        ****
  21:main.c        ****   char y[5] = {'a','b','c','d','e'}; // Although
char arrary is correctly.
 203                   .LM11:
 204 00ae DE01              movw r26,r28
 205 00b0 1896              adiw r26,8
 206 00b2 E0E0              ldi r30,lo8(C.3.1233)
 207 00b4 F0E0              ldi r31,hi8(C.3.1233)
 208 00b6 85E0              ldi r24,lo8(5)
 209                   .L13:
 210 00b8 0490              lpm r0,Z
 211 00ba 0D92              st X+,r0
 212 00bc 8150              subi r24,lo8(-(-1))
 213 00be E1F7              brne .L13
  22:main.c        ****
  23:main.c        ****   volatile vc;
  24:main.c        ****
  25:main.c        ****   long l;
  26:main.c        ****
  27:main.c        ****   v = x[v];
 215                   .LM12:
 216 00c0 8091 0000         lds r24,v
 217 00c4 FE01              movw r30,r28
 218 00c6 E80F              add r30,r24
 219 00c8 F11D              adc r31,__zero_reg__
 220 00ca 8381              ldd r24,Z+3
 221 00cc 8093 0000         sts v,r24
  28:main.c        ****
  29:main.c        ****   v = y[v];
 223                   .LM13:
 224 00d0 8091 0000         lds r24,v
 225 00d4 FE01              movw r30,r28
 226 00d6 E80F              add r30,r24
 227 00d8 F11D              adc r31,__zero_reg__
 228 00da 8085              ldd r24,Z+8
 229 00dc 8093 0000         sts v,r24
 230                   .LBB2:
 231                   .LBB3:
 233                   .LM14:
 234 00e0 DE01              movw r26,r28
 235 00e2 1D96              adiw r26,13
 236 00e4 E0E0              ldi r30,lo8(.LC0)
 237 00e6 F0E0              ldi r31,hi8(.LC0)
 238 00e8 85E0              ldi r24,lo8(5)
 239                   .L14:
 240 00ea 0190              ld r0,Z+
 241 00ec 0D92              st X+,r0
 242 00ee 8150              subi r24,lo8(-(-1))
 243 00f0 E1F7              brne .L14
 245                   .LM15:
 246 00f2 8091 0000         lds r24,v
 247 00f6 FE01              movw r30,r28
 248 00f8 E80F              add r30,r24
 249 00fa F11D              adc r31,__zero_reg__
 250 00fc 8585              ldd r24,Z+13
 251 00fe 8093 0000         sts v,r24
 252                   .LBE3:
 253                   .LBE2:
  30:main.c        ****
  31:main.c        ****   foo();
  32:main.c        ****
  33:main.c        ****   bar();
 255                   .LM16:
 256 0102 0E94 0000         call bar
  34:main.c        ****
  35:main.c        ****   l = vc << 1;
 258                   .LM17:
 259 0106 8981              ldd r24,Y+1
 260 0108 9A81              ldd r25,Y+2
 261 010a 880F              lsl r24
 262 010c 991F              rol r25
 263 010e AA27              clr r26
 264 0110 97FD              sbrc r25,7
 265 0112 A095              com r26
 266 0114 BA2F              mov r27,r26
 267 0116 8160              ori r24,lo8(1)
 268                   /* epilogue: frame size=17 */
 269 0118 0C94 0000         jmp exit
 270                   /* epilogue end (size=2) */
 271                   /* function main size 73 (67) */
 279                   .Lscope2:
 281                       .stabd    78,0,0
 282                       .comm v,1,1
 284                   .Letext0:
 285                   /* File "main.c": code  147 = 0x0093 ( 103),
prologues  24, epilogues  20 */
DEFINED SYMBOLS
                            *ABS*:00000000 main.c
/var/tmp//ccziiwoR.s:3      *ABS*:0000003f __SREG__
/var/tmp//ccziiwoR.s:4      *ABS*:0000003e __SP_H__
/var/tmp//ccziiwoR.s:5      *ABS*:0000003d __SP_L__
/var/tmp//ccziiwoR.s:6      *ABS*:00000000 __tmp_reg__
/var/tmp//ccziiwoR.s:7      *ABS*:00000001 __zero_reg__
/var/tmp//ccziiwoR.s:37     .text:00000000 foo
                            *COM*:00000001 v
/var/tmp//ccziiwoR.s:97     .data:00000006 C.1.1222
/var/tmp//ccziiwoR.s:107    .text:00000048 bar
/var/tmp//ccziiwoR.s:167    .data:0000000b C.3.1233
/var/tmp//ccziiwoR.s:177    .text:00000090 main

UNDEFINED SYMBOLS
__do_copy_data
__do_clear_bss
__stack
__main
exit






Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]