[LLVMdev] Customize Standard C Library Using LLVM (to support llvm backend optimization)
Jonathan Roelofs
jonathan at codesourcery.com
Wed Mar 11 14:53:01 PDT 2015
On 3/11/15 2:24 PM, Chao Yan wrote:
> FWIW, I build baremetal newlib for arm-eabi using clang, and it
> works. I had to patch a few of the __attribute__((naked))
> functions because they were using pre-UAL asm syntax, but for
> the most part it "just works".
>
>
> I build the baremetal newlib using arm-none-eabi-gcc as well, but after
> linking with the hello world program, it failed to run on both qemu-arm
> and gem5.
>
>
>
> Have you considered trying musl? It's supposed to be a full
> replacement for glibc.
>
>
> It looks like a nice alternative, I'll certainly look into it right away.
>
>
> Have you run it in a debugger to figure out *why* it is segfaulting?
> Have you tried building it without your special pass?
>
> Well, I didn't try clang, I use arm-none-eabi-gcc to build the newlib
> and the hello world program. The arm-none-eabi-gdb says "Don't know how
> to run. Try "help target"."
gdb doesn't know how to run your program because gdb only knows how to
run programs natively. You need to run it in qemu, and attach gdb to
that, then debug as if you were debugging natively.
I do something roughly like this (this is from memory, so the actual
commands might be slightly different. ymmv):
$ cat hw.c
#include <stdio.h>
int main() { printf("hello world!\n"); }
$ clang -target arm-none-eabi -march=armv4t hw.c -T generic-hosted.ld
$ qemu-system-arm -semihosting -M integratorcp -cpu arm1026 -kernel
a.out -s -S -g 1234 &
$ arm-none-eabi-gdb
(gdb) target remote localhost:1234
(gdb) file a.out
(gdb) break main
(gdb) r
(gdb) c
hello world!
(gdb) q
$
HTH,
Jon
--
Jon Roelofs
jonathan at codesourcery.com
CodeSourcery / Mentor Embedded
More information about the llvm-dev
mailing list