16-bit linking under linux

I'm using NASM Assembler under linux when I use the command "nasm -f elf -l hello.lst hello.asm" it works fine but when linking with gcc "gcc -o hello hello.o" it generates an error :

hello.asm:(.text+0x4): relocation truncated to fit: R_386_16 against `.data' collect2: ld returned 1 exit status

I learned that this is some problem with gcc and 16-bit

any solutions ?

Answers


Linux doesn't even have a 16-bit subsystem - even if you got gcc to link it, you still couldn't execute it! Why don't you just use .bits 32?


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...).


Need Your Help

How to control Raspberry Pi PiNoIR camera via python?

python camera raspberry-pi

I have a PiNoIR camera for a Raspberry Pi (using Raspbian), and I'd like to control it through a python script. I tried to use the picamera python (2.7) library, but it doesn't work. The camera is

Java SocketPermission policy question

java policy securitymanager

I have a client and server program that attempt to communicate with each other. In my policy file for the server, I have specified the following:

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.