Pregunta

Estoy usando NASM ensamblador bajo Linux cuando se utiliza el comando "nasm -f elf -l hello.lst hello.asm" funciona bien pero cuando se enlaza con gcc "gcc -o hola hola.o" se genera un error:

.

hello.asm :( texto + 0x4): reubicación truncado para caber en: R_386_16 contra `.data' collect2: ld devolvió el código de salida 1

He aprendido que esto es un problema con gcc y 16 bits

alguna solución?

¿Fue útil?

Solución

Linux no tiene ni siquiera un subsistema de 16 bits - incluso si usted tiene gcc para vincularlo, todavía no se podía ejecutarlo! ¿Por qué no sólo tiene que utilizar .bits 32?

Otros consejos

I faced the same situation a few years ago and again this year.

Two ways to deal with it are:

  1. Write your own 16-bit friendly linker (you need to parse .rel.text section at least).
  2. Use a base symbol (or symbols) to calculate the absolute addresses manually (the .rel sections are still created, but can be removed). However, this method is very error prone.

I always end up doing 2, but I should probably make time to write a linker (or patching GNU ld...).

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top