Skip to contentSkip to conversation

Linking assembled PIC code with Linux libc library

DISCUSSION Sergio Ruiz 3 participants 4 messages Apr 9, 2005 – Apr 11, 2005 3 messages not in the archive MIPS

lore
Share & tools
lore
#0 lore raw

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

#1 lore raw
Quoted 4 lines · Sergio Ruiz

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"

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.

Signature · 2 lines
Daniel Jacobowitz
CodeSourcery, LLC

A message that is not in the archive (sent off-list or not yet received): [email protected]

A message that is not in the archive (sent off-list or not yet received): [email protected]

A message that is not in the archive (sent off-list or not yet received): [email protected]

#5 lore raw

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

#6 lore raw
Quoted 3 lines · Sergio Ruiz

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.

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