avr-gcc-list
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[avr-gcc-list] avr-gcc (compiled from trunk) not placing objects in attr


From: David Fernandez
Subject: [avr-gcc-list] avr-gcc (compiled from trunk) not placing objects in attributed sections in some cases.
Date: Wed, 30 Jul 2014 12:31:02 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.6.0

Hi there,

Not sure if this is generic to any gcc target, or it just happens for avr, given previous mentioned problems with the .data section dissappearing (due to -gc-sections) causing.bss to be resolved to the wrong addresses...

Anyway, this is my test case and what happens, which does not happen in the Atmel latest published toolchain:

Test program is:
$ cat gcc-data-sections.c

#if     MAKE_A_PROBLEM
#if     MAKE_IT_WORK
__attribute__((section(".my.tables.things.data")))
#endif/*MAKE_IT_WORK*/
extern unsigned long  my_thing_1;
static unsigned long *my_local_thing = &my_thing_1;
#else /*MAKE_A_PROBLEM*/
static unsigned long *my_local_thing;
#endif/*MAKE_A_PROBLEM*/

__attribute__((section(".my.tables.things.data")))
unsigned long         my_thing_1 = 0x600df00d;


void  my_dummy(void)
{
  (void) my_local_thing; /*avoid a warning*/
}


When compiling with:

$ avr-gcc -mmcu=atxmega256a3u -Wa,-mmcu=atxmega256a3u -Os -g -fsigned-char -ffunction-sections -fdata-sections -Wall -Wextra -Werror -std=gnu99 -DMAKE_A_PROBLEM=1 -DMAKE_IT_WORK=0 -c -o gcc-data-sections.o gcc-data-sections.c

as it usually is done (and does work in the atmel toolchain), I get:

$ avr-objdump -h gcc-data-sections.o

gcc-data-sections.o:     file format elf32-avr

Sections:
Idx Name          Size      VMA       LMA       File off Algn
  0 .text         00000000  00000000  00000000  00000034 2**0
                  CONTENTS, ALLOC, LOAD, READONLY, CODE
  1 .data         00000000  00000000  00000000  00000034 2**0
                  CONTENTS, ALLOC, LOAD, DATA
  2 .bss          00000000  00000000  00000000  00000034 2**0
                  ALLOC
  3 .text.my_dummy 00000002  00000000  00000000  00000034 2**0
                  CONTENTS, ALLOC, LOAD, READONLY, CODE
  4 .data.my_thing_1 00000004  00000000  00000000 00000036  2**0
                  CONTENTS, ALLOC, LOAD, DATA
  5 .debug_info   00000067  00000000  00000000  0000003a 2**0
                  CONTENTS, RELOC, READONLY, DEBUGGING
  6 .debug_abbrev 00000060  00000000  00000000  000000a1 2**0
                  CONTENTS, READONLY, DEBUGGING
  7 .debug_aranges 00000020  00000000  00000000  00000101 2**0
                  CONTENTS, RELOC, READONLY, DEBUGGING
  8 .debug_ranges 00000010  00000000  00000000  00000121 2**0
                  CONTENTS, RELOC, READONLY, DEBUGGING
  9 .debug_line   00000043  00000000  00000000  00000131 2**0
                  CONTENTS, RELOC, READONLY, DEBUGGING
 10 .debug_str    000000e7  00000000  00000000  00000174 2**0
                  CONTENTS, READONLY, DEBUGGING
 11 .comment      0000002b  00000000  00000000  0000025b 2**0
                  CONTENTS, READONLY
 12 .debug_frame  00000024  00000000  00000000  00000288 2**2
                  CONTENTS, RELOC, READONLY, DEBUGGING

With my_thing_1 not going into its assigned section as it should. Found that is due to the previous extern declaration, which seems to work if it is removed:

$ avr-gcc -mmcu=atxmega256a3u -Wa,-mmcu=atxmega256a3u -Os -g -fsigned-char -ffunction-sections -fdata-sections -Wall -Wextra -Werror -std=gnu99 -DMAKE_A_PROBLEM=0 -DMAKE_IT_WORK=0 -c -o gcc-data-sections.o gcc-data-sections.c

$ avr-objdump -h gcc-data-sections.o

gcc-data-sections.o:     file format elf32-avr

Sections:
Idx Name          Size      VMA       LMA       File off  Algn
  0 .text         00000000  00000000  00000000  00000034  2**0
                  CONTENTS, ALLOC, LOAD, READONLY, CODE
  1 .data         00000000  00000000  00000000  00000034  2**0
                  CONTENTS, ALLOC, LOAD, DATA
  2 .bss          00000000  00000000  00000000  00000034  2**0
                  ALLOC
  3 .text.my_dummy 00000002  00000000  00000000  00000034  2**0
                  CONTENTS, ALLOC, LOAD, READONLY, CODE
  4 .my.tables.things.data 00000004  00000000  00000000  00000036 2**0
                  CONTENTS, ALLOC, LOAD, DATA
  5 .debug_info   00000060  00000000  00000000  0000003a  2**0
                  CONTENTS, RELOC, READONLY, DEBUGGING
  6 .debug_abbrev 0000005e  00000000  00000000  0000009a  2**0
                  CONTENTS, READONLY, DEBUGGING
  7 .debug_aranges 00000020  00000000  00000000  000000f8  2**0
                  CONTENTS, RELOC, READONLY, DEBUGGING
  8 .debug_ranges 00000010  00000000  00000000  00000118  2**0
                  CONTENTS, RELOC, READONLY, DEBUGGING
  9 .debug_line   00000043  00000000  00000000  00000128  2**0
                  CONTENTS, RELOC, READONLY, DEBUGGING
 10 .debug_str    000000e7  00000000  00000000  0000016b  2**0
                  CONTENTS, READONLY, DEBUGGING
 11 .comment      0000002b  00000000  00000000  00000252  2**0
                  CONTENTS, READONLY
 12 .debug_frame  00000024  00000000  00000000  00000280  2**2
                  CONTENTS, RELOC, READONLY, DEBUGGING


or if it is annotated with the same section attribute:

$ avr-gcc -mmcu=atxmega256a3u -Wa,-mmcu=atxmega256a3u -Os -g -fsigned-char -ffunction-sections -fdata-sections -Wall -Wextra -Werror -std=gnu99 -DMAKE_A_PROBLEM=1 -DMAKE_IT_WORK=1 -c -o gcc-data-sections.o gcc-data-sections.c

$ avr-objdump -h gcc-data-sections.o

gcc-data-sections.o:     file format elf32-avr

Sections:
Idx Name          Size      VMA       LMA       File off  Algn
  0 .text         00000000  00000000  00000000  00000034  2**0
                  CONTENTS, ALLOC, LOAD, READONLY, CODE
  1 .data         00000000  00000000  00000000  00000034  2**0
                  CONTENTS, ALLOC, LOAD, DATA
  2 .bss          00000000  00000000  00000000  00000034  2**0
                  ALLOC
  3 .text.my_dummy 00000002  00000000  00000000  00000034  2**0
                  CONTENTS, ALLOC, LOAD, READONLY, CODE
  4 .my.tables.things.data 00000004  00000000  00000000  00000036 2**0
                  CONTENTS, ALLOC, LOAD, DATA
  5 .debug_info   00000067  00000000  00000000  0000003a  2**0
                  CONTENTS, RELOC, READONLY, DEBUGGING
  6 .debug_abbrev 00000060  00000000  00000000  000000a1  2**0
                  CONTENTS, READONLY, DEBUGGING
  7 .debug_aranges 00000020  00000000  00000000  00000101  2**0
                  CONTENTS, RELOC, READONLY, DEBUGGING
  8 .debug_ranges 00000010  00000000  00000000  00000121  2**0
                  CONTENTS, RELOC, READONLY, DEBUGGING
  9 .debug_line   00000043  00000000  00000000  00000131  2**0
                  CONTENTS, RELOC, READONLY, DEBUGGING
 10 .debug_str    000000e7  00000000  00000000  00000174  2**0
                  CONTENTS, READONLY, DEBUGGING
 11 .comment      0000002b  00000000  00000000  0000025b  2**0
                  CONTENTS, READONLY
 12 .debug_frame  00000024  00000000  00000000  00000288  2**2
                  CONTENTS, RELOC, READONLY, DEBUGGING


The atmel gcc is:
$ avr-gcc -v
Using built-in specs.
COLLECT_GCC=avr-gcc
COLLECT_LTO_WRAPPER=/misc/apps/avr8/avr8-gnu-toolchain-linux_x86_64/bin/../libexec/gcc/avr/4.8.1/lto-wrapper
Target: avr
Configured with: /data2/home/toolsbuild/jenkins-knuth/workspace/avr8-gnu-toolchain/src/gcc/configure LDFLAGS=-L/home/toolsbuild/jenkins-knuth/workspace/avr8-gnu-toolchain/avr8-gnu-toolchain-linux_x86_64/lib CPPFLAGS= --target=avr --host=x86_64-pc-linux-gnu --build=x86_64-pc-linux-gnu --prefix=/home/toolsbuild/jenkins-knuth/workspace/avr8-gnu-toolchain/avr8-gnu-toolchain-linux_x86_64 --libdir=/home/toolsbuild/jenkins-knuth/workspace/avr8-gnu-toolchain/avr8-gnu-toolchain-linux_x86_64/lib --enable-languages=c,c++ --with-dwarf2 --enable-doc --disable-shared --disable-libada --disable-libssp --disable-nls --with-avrlibc=yes --with-mpfr=/home/toolsbuild/jenkins-knuth/workspace/avr8-gnu-toolchain/avr8-gnu-toolchain-linux_x86_64 --with-gmp=/home/toolsbuild/jenkins-knuth/workspace/avr8-gnu-toolchain/avr8-gnu-toolchain-linux_x86_64 --with-mpc=/home/toolsbuild/jenkins-knuth/workspace/avr8-gnu-toolchain/avr8-gnu-toolchain-linux_x86_64 --enable-fixed-point --with-pkgversion=AVR_8_bit_GNU_Toolchain_3.4.3_1072 --with-bugurl=http://www.atmel.com
Thread model: single
gcc version 4.8.1 (AVR_8_bit_GNU_Toolchain_3.4.3_1072)

The trunk version from yesterday that I built (using also trunk binutils and trunk avr-libc) is:
$ avr-gcc -v
Using built-in specs.
COLLECT_GCC=avr-gcc
COLLECT_LTO_WRAPPER=/misc/apps/avr8/tools_002/libexec/gcc/avr/4.10.0/lto-wrapper
Target: avr
Configured with: /home/df/src/gcc-trunk/configure --prefix=/misc/apps/avr8/tools_002 --target=avr --enable-languages=c,c++ --with-gnu-as --with-gnu-ld --with-dwarf2 --with-avrlibc=yes --enable-fixed-point --enable-doc --disable-libssp --disable-libada --disable-shared -v
Thread model: single
gcc version 4.10.0 20140729 (experimental) (GCC)

Other than that (and a bit more picky with aggregate initializers that don't include all the elements), it builds functional firmware properly.

Greetings
David Fernandez



reply via email to

[Prev in Thread] Current Thread [Next in Thread]