.a file not linking correctly

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

 



Hi!

I am new to the list but I work with gcc and cross-compiling for
several years. Now I am facing something new: I can generate a .elf
file from *.o files. If I join the same files in a .a file and try to
use it instead of *.o files, I always get an empty file. Please note:
it is not an zero size file, just empty elf... It is a valid .elf file
but without any sections.

Here is the commands and output for better understanding:

First, commands without using a .a file:

arm-none-eabi-gcc -mcpu=cortex-m4 -mfpu=fpv4-sp-d16 -mfloat-abi=hard
-mthumb -Wall -g -nostartfiles -Wl,-Map=Lpc407x.map -O0
-Wl,--gc-sections -LC:\CooCox\CoIDE\configuration\ProgramData\Lpc407x
-Wl,-TC:\CooCox\CoIDE\configuration\ProgramData\Lpc407x/arm-gcc-link.ld
-g -o Lpc407x.elf poptools.c ..\obj\*.o

File generated by gcc: Lpc407x.elf with 539.496 bytes. objdump shows:

arm-none-eabi-objdump -h Lpc407x.elf


Lpc407x.elf:     file format elf32-littlearm

Sections:
Idx Name          Size      VMA       LMA       File off  Algn
  0 .text         000195e4  00000000  00000000  00008000  2**3
                  CONTENTS, ALLOC, LOAD, READONLY, CODE
  1 .ARM.exidx    00000008  000195e4  000195e4  000215e4  2**2
                  CONTENTS, ALLOC, LOAD, READONLY, DATA
  2 .data         00000bd4  10000000  000195ec  00028000  2**3
                  CONTENTS, ALLOC, LOAD, DATA
  3 .bss          0000689c  10000bd8  0001a1c8  00028bd8  2**3
                  ALLOC
  4 .co_stack     00000404  10007474  00020a64  00028bd8  2**2
                  ALLOC
  5 .debug_info   00025103  00000000  00000000  00028bd4  2**0
                  CONTENTS, READONLY, DEBUGGING
  6 .debug_abbrev 00007ade  00000000  00000000  0004dcd7  2**0
                  CONTENTS, READONLY, DEBUGGING
  7 .debug_aranges 00001fc0  00000000  00000000  000557b5  2**0
                  CONTENTS, READONLY, DEBUGGING
  8 .debug_line   0000dc4f  00000000  00000000  00057775  2**0
                  CONTENTS, READONLY, DEBUGGING
  9 .debug_str    000089d3  00000000  00000000  000653c4  2**0
                  CONTENTS, READONLY, DEBUGGING
 10 .comment      00000070  00000000  00000000  0006dd97  2**0
                  CONTENTS, READONLY
 11 .ARM.attributes 00000037  00000000  00000000  0006de07  2**0
                  CONTENTS, READONLY
 12 .debug_frame  00007280  00000000  00000000  0006de40  2**2
                  CONTENTS, READONLY, DEBUGGING
 13 .debug_ranges 00001b20  00000000  00000000  000750c0  2**0
                  CONTENTS, READONLY, DEBUGGING


Second, create a .a file and use it to link instead of *.o files

arm-none-eabi-ar rvs libpop.a ..\obj\*.o

arm-none-eabi-gcc -mcpu=cortex-m4 -mfpu=fpv4-sp-d16 -mfloat-abi=hard
-mthumb -Wall -g -nostartfiles -Wl,-Map=Lpc407x.map -O0
-Wl,--gc-sections -LC:\CooCox\CoIDE\configuration\ProgramData\Lpc407x
-Wl,-TC:\CooCox\CoIDE\configuration\ProgramData\Lpc407x/arm-gcc-link.ld
-g -o Lpc407x.elf poptools.c libpop.a

ar output:

arm-none-eabi-ar: creating libpop.a
a - ..\obj\adc.o
a - ..\obj\adc_17xx_40xx.o
a - ..\obj\api_lib.o
...
...
(a lot of other .o files)
...
...
a - ..\obj\wwdt_17xx_40xx.o
a - ..\obj\yaskawa.o

File generated by gcc: Lpc407x.elf with 902 bytes. objdump shows:

arm-none-eabi-objdump -h Lpc407x.elf

Lpc407x.elf:     file format elf32-littlearm

Sections:
Idx Name          Size      VMA       LMA       File off  Algn


I am using GCC 4.8 update 3 (4.8.4) from
https://launchpad.net/gcc-arm-embedded/+announcement/12983
Is there something I am missing?

Best regards,
Marcelo Utikawa da Fonseca




[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux