]> git.pld-linux.org Git - packages/crossavr-gcc.git/blob - 502-gcc-4.5.1-bug-18145-v4.patch
1115f35d404e97aa678a8e048a38083c553bf65e
[packages/crossavr-gcc.git] / 502-gcc-4.5.1-bug-18145-v4.patch
1 diff -Naurp gcc/config/avr/avr.c gcc/config/avr/avr.c
2 --- gcc/config/avr/avr.c        2011-06-09 15:41:06.000000000 -0500
3 +++ gcc/config/avr/avr.c        2011-06-09 15:46:03.000000000 -0500
4 @@ -81,6 +81,12 @@ static rtx avr_function_value (const_tre
5  static void avr_insert_attributes (tree, tree *);
6  static void avr_asm_init_sections (void);
7  static unsigned int avr_section_type_flags (tree, const char *, int);
8 +static void avr_asm_named_section (const char *name, unsigned int flags, tree decl);
9 +/* Track if code will use .bss and/or .data */
10 +static int avr_need_clear_bss_p = 0;
11 +static int avr_need_copy_data_p = 0;
12 +static void avr_output_data_section_asm_op (const void*);
13 +static void avr_output_bss_section_asm_op (const void*);
14  
15  static void avr_reorg (void);
16  static void avr_asm_out_ctor (rtx, int);
17 @@ -6102,6 +6108,54 @@ avr_output_progmem_section_asm_op (const
18    fprintf (asm_out_file, "\t.p2align 1\n");
19  }
20  
21 +/* ASM_OUTPUT_COMMON */
22 +/* Track need of __do_clear_bss */
23 +
24 +void
25 +avr_asm_output_common (FILE *stream, const char *name,
26 +                       unsigned HOST_WIDE_INT size,
27 +                       unsigned HOST_WIDE_INT rounded ATTRIBUTE_UNUSED)
28 +{
29 +    avr_need_clear_bss_p = 1;
30 +    fputs ("\t.comm ", stream);
31 +    assemble_name (stream, name);
32 +    fprintf (stream, ",%lu,1\n", (unsigned long) size);  
33 +}
34 +
35 +/* ASM_OUTPUT_LOCAL */
36 +/* Track need of __do_clear_bss */
37 +
38 +void
39 +avr_asm_output_local (FILE *stream, const char *name,
40 +                      unsigned HOST_WIDE_INT size,
41 +                      unsigned HOST_WIDE_INT rounded ATTRIBUTE_UNUSED)
42 +{                                                    
43 +    avr_need_clear_bss_p = 1;                           
44 +    fputs ("\t.lcomm ", stream);                      
45 +    assemble_name (stream, name);                   
46 +    fprintf (stream, ",%d\n", (int) size);           
47 +}
48 +
49 +/* Unnamed section callback to track need of __do_copy_data */
50 +
51 +static void
52 +avr_output_data_section_asm_op (const void *data)
53 +{
54 +    avr_need_copy_data_p = 1;
55 +    /* Dispatch to default */
56 +    output_section_asm_op (data);
57 +}
58 +
59 +/* Unnamed section callback to track need of __do_clear_bss */
60 +
61 +static void
62 +avr_output_bss_section_asm_op (const void *data)
63 +{
64 +    avr_need_clear_bss_p = 1;
65 +    /* Dispatch to default */
66 +    output_section_asm_op (data);
67 +}
68 +
69  /* Implement TARGET_ASM_INIT_SECTIONS.  */
70  
71  static void
72 @@ -6111,6 +6165,27 @@ avr_asm_init_sections (void)
73                                          avr_output_progmem_section_asm_op,
74                                          NULL);
75    readonly_data_section = data_section;
76 +
77 +  data_section->unnamed.callback = avr_output_data_section_asm_op;
78 +  bss_section->unnamed.callback = avr_output_bss_section_asm_op;
79 +}
80 +
81 +/* TARGET_ASM_NAMED_SECTION */
82 +/* Track need of __do_clear_bss, __do_copy_data for named sections */
83 +
84 +static void
85 +avr_asm_named_section (const char *name, unsigned int flags, tree decl)
86 +{
87 +    if (!avr_need_copy_data_p)
88 +        avr_need_copy_data_p =
89 +            (0 == strncmp (name, ".data", 5)
90 +             || 0 == strncmp (name, ".rodata", 7)
91 +             || 0 == strncmp (name, ".gnu.linkonce.", 14));
92 +    
93 +    if (!avr_need_clear_bss_p)
94 +        avr_need_clear_bss_p = (0 == strncmp (name, ".bss", 4));
95 +    
96 +    default_elf_asm_named_section (name, flags, decl);
97  }
98  
99  static unsigned int
100 @@ -6152,12 +6227,6 @@ avr_file_start (void)
101    AVR_TINY ? fputs ("__tmp_reg__ = 16\n" 
102                             "__zero_reg__ = 17\n", asm_out_file) : fputs ("__tmp_reg__ = 0\n" 
103           "__zero_reg__ = 1\n", asm_out_file);
104 -
105 -  /* FIXME: output these only if there is anything in the .data / .bss
106 -     sections - some code size could be saved by not linking in the
107 -     initialization code from libgcc if one or both sections are empty.  */
108 -  fputs ("\t.global __do_copy_data\n", asm_out_file);
109 -  fputs ("\t.global __do_clear_bss\n", asm_out_file);
110  }
111  
112  /* Outputs to the stdio stream FILE some
113 @@ -6166,6 +6235,16 @@ avr_file_start (void)
114  static void
115  avr_file_end (void)
116  {
117 +    /* Output these only if there is anything in the
118 +       .data* / .rodata* / .gnu.linkonce.* resp. .bss*
119 +       input section(s) - some code size can be saved by not
120 +       linking in the initialization code from libgcc if resp.
121 +       sections are empty. */
122 +    if (avr_need_copy_data_p)
123 +        fputs (".global __do_copy_data\n", asm_out_file);
124 +    
125 +    if (avr_need_clear_bss_p)
126 +        fputs (".global __do_clear_bss\n", asm_out_file);
127  }
128  
129  /* Choose the order in which to allocate hard registers for
130 diff -Naurp gcc/config/avr/avr.h gcc/config/avr/avr.h
131 --- gcc/config/avr/avr.h        2011-06-09 14:30:33.000000000 -0500
132 +++ gcc/config/avr/avr.h        2011-06-09 15:46:03.000000000 -0500
133 @@ -562,7 +562,7 @@ do {                                                                            \
134  #define ASM_APP_OFF "/* #NOAPP */\n"
135  
136  /* Switch into a generic section.  */
137 -#define TARGET_ASM_NAMED_SECTION default_elf_asm_named_section
138 +#define TARGET_ASM_NAMED_SECTION avr_asm_named_section
139  #define TARGET_ASM_INIT_SECTIONS avr_asm_init_sections
140  
141  #define ASM_OUTPUT_ASCII(FILE, P, SIZE)         gas_output_ascii (FILE,P,SIZE)
142 @@ -570,21 +570,13 @@ do {                                                                          \
143  #define IS_ASM_LOGICAL_LINE_SEPARATOR(C, STR) ((C) == '\n' || ((C) == '$'))
144  
145  #define ASM_OUTPUT_COMMON(STREAM, NAME, SIZE, ROUNDED)                    \
146 -do {                                                                      \
147 -     fputs ("\t.comm ", (STREAM));                                        \
148 -     assemble_name ((STREAM), (NAME));                                    \
149 -     fprintf ((STREAM), ",%lu,1\n", (unsigned long)(SIZE));               \
150 -} while (0)
151 +        avr_asm_output_common (STREAM, NAME, SIZE, ROUNDED)
152  
153  #define ASM_OUTPUT_BSS(FILE, DECL, NAME, SIZE, ROUNDED)                        \
154    asm_output_bss ((FILE), (DECL), (NAME), (SIZE), (ROUNDED))
155  
156  #define ASM_OUTPUT_LOCAL(STREAM, NAME, SIZE, ROUNDED)                  \
157 -do {                                                                   \
158 -     fputs ("\t.lcomm ", (STREAM));                                    \
159 -     assemble_name ((STREAM), (NAME));                                 \
160 -     fprintf ((STREAM), ",%d\n", (int)(SIZE));                         \
161 -} while (0)
162 +        avr_asm_output_local (STREAM, NAME, SIZE, ROUNDED)
163  
164  #undef TYPE_ASM_OP
165  #undef SIZE_ASM_OP
166 diff -Naurp gcc/config/avr/avr-protos.h gcc/config/avr/avr-protos.h
167 --- gcc/config/avr/avr-protos.h 2011-06-09 14:30:33.000000000 -0500
168 +++ gcc/config/avr/avr-protos.h 2011-06-09 15:46:03.000000000 -0500
169 @@ -35,6 +35,9 @@ extern int avr_simple_epilogue (void);
170  extern void gas_output_limited_string (FILE *file, const char *str);
171  extern void gas_output_ascii (FILE *file, const char *str, size_t length);
172  extern int avr_hard_regno_rename_ok (unsigned int, unsigned int);
173 +extern void avr_asm_output_common (FILE *stream, const char *name, unsigned HOST_WIDE_INT size, unsigned HOST_WIDE_INT rounded);
174 +extern void avr_asm_output_local (FILE *stream, const char *name, unsigned HOST_WIDE_INT size, unsigned HOST_WIDE_INT rounded);
175 +  
176  extern rtx avr_return_addr_rtx (int count, const_rtx tem);
177  
178  #ifdef TREE_CODE
This page took 0.028769 seconds and 2 git commands to generate.