Well... as you probably know, Nasm will condescend to do a shift on the difference between two labels. The usual construct is something like:
dw (int3 - $$) >> 16
where $$
refers to the beginning of the section. This calculates the "file offset". This is probably not the value you want to shift.
dw (int3 - $$ + ORIGIN) >> 16
may do what you want... where ORIGIN
is... well, what we told Nasm for org
, if we were using flat binary. I ASSume you're assembling to -f elf32
or -f elf64
, telling ld --oformat=binary
, and telling ld either in a linker script or on the command line where you want .text
to be (?). This seems to work.
I made an interesting discovery: if you tell ld -oformat=binary
(one hyphen) instead of --oformat=binary
(two hyphens), ld silently outputs nothing! Don't do this - you waste a lot of time!