From martin.velek at gmail.com Thu Sep 13 09:33:18 2012 From: martin.velek at gmail.com (Martin Velek) Date: Thu, 13 Sep 2012 11:33:18 +0200 Subject: [arm-gnu] cs3 adding support for a new family of nxp - lpc, bug report Message-ID: Hello, I have downloaded a 30 trial version of codesourcery (mentor) toolchain - Sourcery CodeBench 2012.03-28 to try it. Because the nxp lpc1788 (cortex m3) is not supported (or board with some lpc1788), I have generated a new Board definition based on Keil MCB1760. The nxp lpc1788 has slightly different interrupt vector model than the predefined in CodeBench (lpc1769). From that reason, I have copied lpc17xx-isrs.S, lpc17xx-vector.S and lpc17xx-names.inc to my project folder and added lines like .long__cs3_isr_uart4, etc. to lpc17xx-vector.S. The same with lpc17xx-isrs.S and lpc17xx-names.inc, I have only copied the lines and added a new suffix with a proper name like uart4, lcd, etc. Now, when I compile it, I get error lpc17xx-vector.o:(.cs3.interrupt_vector+0xe0): undefined reference to `__cs3_isr_uart4'. To get rid of this message, I have defined the __cs3_isr_uart4 in lpc17xx-isrs.S .weak __cs3_isr_uart4 .globl __cs3_isr_uart4 .set __cs3_isr_uart4, __cs3_isr_interrupt .type __cs3_isr_uart4, %function __cs3_isr_uart4: b . but this wastes a rom memory. Other interrupts, if not used, are mapped to a default handler __cs3_isr_interrupt. I do not know, how to make the linker to replace this symbol __cs3_isr_uart4 with an address of __cs3_isr_interrupt if the interrupt is not used. With wasting of memory is related my second post. I am trying to create a second stage bootloader which should fit into first sector (4096 B). For that reason, I would like to reduce the size as much as possible, e.g. by removing functions like frame_dummy, __do_global_dtors_aux, __cs3_start_c, etc. It is only possible when I remove libraries (cs3, cs3unhosted) in a linker script (GROUP) and set flags -nostartfiles, -nodefaultlibraries, -nostdlib. When I do this, I get an error about reporting a bug, so I am doing it: /home/velek/CodeSourcery/Sourcery_CodeBench_for_ARM_EABI/bin/../lib/gcc/arm-none-eabi/4.6.3/../../../../arm-none-eabi/bin/ld: BFD (Sourcery CodeBench 2012.03-28) 2.21.53.20110905 internal error, aborting at /scratch/janisjo/2012.03-arm-eabi-release/obj/binutils-src-2012.03-28-arm-none-eabi-i686-pc-linux-gnu/bfd/elflink.c line 9102 in elf_link_output_extsym /home/velek/CodeSourcery/Sourcery_CodeBench_for_ARM_EABI/bin/../lib/gcc/arm-none-eabi/4.6.3/../../../../arm-none-eabi/bin/ld: Please report this bug. The project is in the enclosure. Thank you for any help Regards Martin Velek -------------- next part -------------- A non-text attachment was scrubbed... Name: lpc1788.zip Type: application/zip Size: 20858 bytes Desc: not available URL: From robert.pinsker at st.com Mon Sep 17 13:57:29 2012 From: robert.pinsker at st.com (Robert PINSKER) Date: Mon, 17 Sep 2012 15:57:29 +0200 Subject: [arm-gnu] Static linking with clock_gettime Message-ID: <0377A834DA6BD146B60DE19D099928BFC70DA6676C@SAFEX1MAIL2.st.com> Hi All, I need to link an executable statically but ideally I want to include clock_gettime in this code, which normally causes a link failure with a static link. It's been suggested that I need glibc-static-devel or some such to do this. How can I do this with CodeSourcery? Thanks Robert Pinsker ST, Bristol -------------- next part -------------- An HTML attachment was scrubbed... URL: From carlos_odonell at mentor.com Mon Sep 17 14:02:03 2012 From: carlos_odonell at mentor.com (Carlos O'Donell) Date: Mon, 17 Sep 2012 10:02:03 -0400 Subject: [arm-gnu] Static linking with clock_gettime In-Reply-To: <0377A834DA6BD146B60DE19D099928BFC70DA6676C@SAFEX1MAIL2.st.com> References: <0377A834DA6BD146B60DE19D099928BFC70DA6676C@SAFEX1MAIL2.st.com> Message-ID: <50572D5B.9020509@mentor.com> On 9/17/2012 9:57 AM, Robert PINSKER wrote: > I need to link an executable statically but ideally I want to > include clock_gettime in this code, which normally causes a link > failure with a static link. It?s been suggested that I need > glibc-static-devel or some such to do this. How can I do this with > CodeSourcery? We automatically ship all the pieces you need to do a static link. Exactly what error message are you getting? Can you provide a simple example? Cheers, Carlos. -- Carlos O'Donell Mentor Graphics / CodeSourcery carlos_odonell at mentor.com carlos at codesourcery.com +1 (613) 963 1026 From carlos_odonell at mentor.com Mon Sep 17 14:33:26 2012 From: carlos_odonell at mentor.com (Carlos O'Donell) Date: Mon, 17 Sep 2012 10:33:26 -0400 Subject: [arm-gnu] Static linking with clock_gettime In-Reply-To: <0377A834DA6BD146B60DE19D099928BFC70DA6678B@SAFEX1MAIL2.st.com> References: <0377A834DA6BD146B60DE19D099928BFC70DA6676C@SAFEX1MAIL2.st.com> <50572D5B.9020509@mentor.com> <0377A834DA6BD146B60DE19D099928BFC70DA6678B@SAFEX1MAIL2.st.com> Message-ID: <505734B6.9060002@mentor.com> On 9/17/2012 10:12 AM, Robert PINSKER wrote: > Thanks for your really fast reply! > > The link command & the error message is as follows: > > /design/HED_A9SS/CodeSourcery/Sourcery_G++_Lite/2011.03/bin/arm-none-linux-gnueabi-gcc > -O3 -DUSE_CLOCK=0 -DUSE_FORK=1 -lrt -funroll-loops -fgcse-sm > -falign-loops=8 -combine -mfloat-abi=soft -mfpu=vfp3 -Iarm -I. > -DFLAGS_STR=\""-O3 -DUSE_CLOCK=0 -DUSE_FORK=1 -lrt -funroll-loops > -fgcse-sm -falign-loops=8 -combine -mfloat-abi=soft -mfpu=vfp3 > -DCORE_DEBUG=1 -static "\" -DITERATIONS=0 -DCORE_DEBUG=1 > core_list_join.c core_main.c core_matrix.c core_state.c core_util.c > arm/core_portme.c -o ./coremark.exe -static > /tmp/ccDw13Kv.o: In function `main': > core_list_join.c:(.text+0x558c): undefined reference to `clock_gettime' > core_list_join.c:(.text+0x55a0): undefined reference to `clock_gettime' > core_list_join.c:(.text+0x618c): undefined reference to `clock_gettime' > core_list_join.c:(.text+0x61a0): undefined reference to `clock_gettime' > /tmp/ccDw13Kv.o: In function `start_time': > core_list_join.c:(.text+0x93cc): undefined reference to `clock_gettime' > /tmp/ccDw13Kv.o:core_list_join.c:(.text+0x93dc): more undefined references to `clock_gettime' follow > collect2: ld returned 1 exit status > make: *** [compile] Error 1 Please keep the list in the CC, that way others can learn from your questions. Link order matters in a static link. The file core_list_join.c has an undefined reference to `clock_gettime', but you have no *subsequent* static archive on the link list that provides the definition. Move `-lrt' to the end of the command line to provide a definition *after* the reference that needs it. If you can't change the link order you can work around this using --whole-archive, but this will increase your binary size by including things you may not need from the library. If you ever have circular references look at --start-group/--end-group. Cheers, Carlos. -- Carlos O'Donell Mentor Graphics / CodeSourcery carlos_odonell at mentor.com carlos at codesourcery.com +1 (613) 963 1026 From robert.pinsker at st.com Mon Sep 17 16:20:02 2012 From: robert.pinsker at st.com (Robert PINSKER) Date: Mon, 17 Sep 2012 18:20:02 +0200 Subject: [arm-gnu] Static linking with clock_gettime In-Reply-To: <505734B6.9060002@mentor.com> References: <0377A834DA6BD146B60DE19D099928BFC70DA6676C@SAFEX1MAIL2.st.com> <50572D5B.9020509@mentor.com> <0377A834DA6BD146B60DE19D099928BFC70DA6678B@SAFEX1MAIL2.st.com> <505734B6.9060002@mentor.com> Message-ID: <0377A834DA6BD146B60DE19D099928BFC70DA6684E@SAFEX1MAIL2.st.com> You are quite right, thanks, I should have thought of that. Robert. -----Original Message----- From: Carlos O'Donell [mailto:carlos_odonell at mentor.com] Sent: 17 September 2012 15:33 To: Robert PINSKER; arm-gnu at codesourcery.com Subject: Re: [arm-gnu] Static linking with clock_gettime On 9/17/2012 10:12 AM, Robert PINSKER wrote: > Thanks for your really fast reply! > > The link command & the error message is as follows: > > /design/HED_A9SS/CodeSourcery/Sourcery_G++_Lite/2011.03/bin/arm-none-l > inux-gnueabi-gcc > -O3 -DUSE_CLOCK=0 -DUSE_FORK=1 -lrt -funroll-loops -fgcse-sm > -falign-loops=8 -combine -mfloat-abi=soft -mfpu=vfp3 -Iarm -I. > -DFLAGS_STR=\""-O3 -DUSE_CLOCK=0 -DUSE_FORK=1 -lrt -funroll-loops > -fgcse-sm -falign-loops=8 -combine -mfloat-abi=soft -mfpu=vfp3 > -DCORE_DEBUG=1 -static "\" -DITERATIONS=0 -DCORE_DEBUG=1 > core_list_join.c core_main.c core_matrix.c core_state.c core_util.c > arm/core_portme.c -o ./coremark.exe -static > /tmp/ccDw13Kv.o: In function `main': > core_list_join.c:(.text+0x558c): undefined reference to `clock_gettime' > core_list_join.c:(.text+0x55a0): undefined reference to `clock_gettime' > core_list_join.c:(.text+0x618c): undefined reference to `clock_gettime' > core_list_join.c:(.text+0x61a0): undefined reference to `clock_gettime' > /tmp/ccDw13Kv.o: In function `start_time': > core_list_join.c:(.text+0x93cc): undefined reference to `clock_gettime' > /tmp/ccDw13Kv.o:core_list_join.c:(.text+0x93dc): more undefined > references to `clock_gettime' follow > collect2: ld returned 1 exit status > make: *** [compile] Error 1 Please keep the list in the CC, that way others can learn from your questions. Link order matters in a static link. The file core_list_join.c has an undefined reference to `clock_gettime', but you have no *subsequent* static archive on the link list that provides the definition. Move `-lrt' to the end of the command line to provide a definition *after* the reference that needs it. If you can't change the link order you can work around this using --whole-archive, but this will increase your binary size by including things you may not need from the library. If you ever have circular references look at --start-group/--end-group. Cheers, Carlos. -- Carlos O'Donell Mentor Graphics / CodeSourcery carlos_odonell at mentor.com carlos at codesourcery.com +1 (613) 963 1026