a5hk
a5hk

Reputation: 7834

Is it possible to link 16-bit code and 32-bit code?

I have asked a related question here. Now I have more basic question, I mean my original question is changed so I decided to ask a new one. I don't have much experience in linker scripts and makefiles. Reading the following four files setup.ld, Makefile, bioscall.S and pmjump.S from linux, I think it is possible (working) is it right or not?

In bioscall.S:

.code16
.section ".inittext","ax"

In pmjump.S:

.code32
.section ".text32","ax"

In setup.ld:

.inittext       : { *(.inittext) }

and

.text32         : { *(.text32) }

Upvotes: 1

Views: 227

Answers (2)

rcgldr
rcgldr

Reputation: 28826

This could be possible if using an ARM processor, where 16 bit code is "thumb" mode, 16 bit instructions, with 32 bit registers, and 32 bit code is "arm" mode, 32 bit instructions with 32 bit registers. ARM tool sets also use ELF.

Upvotes: 0

Igor Skochinsky
Igor Skochinsky

Reputation: 25288

The ELF format does not have a 16-bit variant, so your 16-bit code will be placed into 32-bit sections. And yes, those can be linked together with "real" 32-bit code. Whether the result will work is a different question.

Upvotes: 1

Related Questions