This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: 8bit and 16bit relocations in gold


Andi Kleen wrote:
Ian,

With the help of H. Peter Anvin I poked a bit more at the gold linux kernel boot problems.

First the crash happen really in the real mode code which has 8 and 16bit
relocations (arch/x86/boot/* in a modern linux kernel tree). This is
generated from a custom linker script (arch/x86/boot/setup.ld)


Comparing to a good kernel we already see some differences just in the header:

e.g. in the setup.bin which is just the binary dump of that code

-0000200 46eb 6448 5372 0207 0000 0000 1000 2900 (bfd)
+0000200 46eb 6449 5372 0207 0000 0000 1000 2900 (gold)


which is generated from this assembler code in header.S

        .section ".header", "a"
        .globl  hdr
hdr:
setup_sects:    .byte SETUPSECTS
root_flags:     .word ROOT_RDONLY
syssize:        .long SYSSIZE
ram_size:       .word RAMDISK
vid_mode:       .word SVGA_MODE
root_dev:       .word ROOT_DEV
boot_flag:      .word 0xAA55


Actually, that snippet *ends* at 0x200, the code that generates the snipped above is:


# offset 512, entry point

        .globl  _start
_start:
                # Explicitly enter this as bytes, or the assembler
                # tries to generate a 3-byte jump here, which causes
                # everything else to push off to the wrong offset.
                .byte   0xeb            # short (2-byte) jump
                .byte   start_of_setup-1f
1:

# Part 2 of the header, from the old setup.S

.ascii "HdrS" # header signature
.word 0x0208 # header version number (>= 0x0105)
# or else old loadlin-1.5 will fail)
.globl realmode_swtch
realmode_swtch: .word 0, 0 # default_switch, SETUPSEG
start_sys_seg: .word SYSSEG
.word kernel_version-512 # pointing to kernel version string
# above section of header is compatible
# with loadlin-1.5 (header v1.5). Don't
# change it.


The second .byte is what generates the R_386_PC8 relocation.

-hpa


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]