Subject: Linking assembled PIC code with Linux libc library

From: Sergio Ruiz <[email-masked]>
Date: Sat, 9 Apr 2005 14:09:14 +0200

Hi, i can't link assembled pic code against the libc running my
embedded-mips-box under debian, and this is what i do:

bluebox@bluebox:~$ as -al -EL -membedded-pic -mips1 -o prueba."o" prueba."s"

ld -L/usr/lib -lc -EL -o prueba prueba.o
ld: aviso: no se puede encontrar el símbolo de entrada __start; usando
por omisión 0000000000400280
prueba.o: En la función `main':
prueba.o(.text+0x8): relocation truncated to fit: R_MIPS_GNU_REL16_S2
printf@@GLIBC_2.0

I've been looking everywhere without any luck.
Any help is appreciated!
Thanks

---

From: Daniel Jacobowitz <[email-masked]>
Date: Sat, 9 Apr 2005 09:49:19 -0400

> bluebox@bluebox:~$ as -al -EL -membedded-pic -mips1 -o prueba."o" prueba."s"

PIC != embedded-pic.  You shouldn't be using -membedded-pic.

In fact, you shouldn't be using as directly, or ld.  Always use GCC to
assemble and link, and it will take care of the options for you.

-- 
Daniel Jacobowitz
CodeSourcery, LLC

---

From: Sergio Ruiz <[email-masked]>
Date: Sun, 10 Apr 2005 21:27:58 +0200

But if I use GCC with my assembler code, and I use a simple 'printf'
function, the assembler code I get is totally different than the
original one, so I cant debug it.

any other possibility?

thanks,

Sergio

---

From: Ralf Baechle <[email-masked]>
Date: Mon, 11 Apr 2005 17:09:47 +0100

> original one, so I cant debug it.

Sounds like you're being surprised by the gcc 3.4 optimization where gcc
may replace certain functions such as printf with a whole sequence of
calls to more basic stdio functions?

  Ralf