bonzini / qboot

Minimal x86 firmware for booting Linux kernels
GNU General Public License v2.0
704 stars 118 forks source link

bios.bin is 66k due to reloc section #26

Closed osresearch closed 4 years ago

osresearch commented 4 years ago

The objcopy -Obinary is leaving a relocation section which makes the resultant binary 66696 bytes long. readelf -a reports:

Section Headers:
  [Nr] Name              Type            Addr     Off    Size   ES Flg Lk Inf Al
...
  [13] .rel.dyn          REL             00100000 007000 000488 08   A  5   0  4
bonzini commented 4 years ago

With what build system is this? I cannot reproduce it in Fedora.

  [Nr] Name              Type             Address           Offset
       Size              EntSize          Flags  Link  Info  Align
  [ 0]                   NULL             0000000000000000  00000000
       0000000000000000  0000000000000000           0     0     0
  [ 1] .text             PROGBITS         00000000000f0000  000f0000
       0000000000001ec5  0000000000000000  AX       0     0     16
  [ 2] .data             PROGBITS         00000000000f1ed0  000f1ed0
       0000000000000008  0000000000000000  WA       0     0     4
  [ 3] .rodata           PROGBITS         00000000000f1ee0  000f1ee0
       0000000000000068  0000000000000000   A       0     0     4
  [ 4] .eh_frame         PROGBITS         00000000000f1f48  000f1f48
       00000000000008c8  0000000000000000   A       0     0     4
  [ 5] .rodata.str1.1    PROGBITS         00000000000f2810  000f2810
       0000000000000034  0000000000000001 AMS       0     0     1
  [ 6] .bss              NOBITS           00000000000f2860  000f2844
       0000000000000080  0000000000000000  WA       0     0     32
  [ 7] .init             PROGBITS         00000000000fff80  000fff80
       0000000000000080  0000000000000000  AX       0     0     16
  [ 8] .comment          PROGBITS         0000000000000000  00100000
       000000000000002c  0000000000000001  MS       0     0     1
  [ 9] .shstrtab         STRTAB           0000000000000000  0010002c
       000000000000004c  0000000000000000           0     0     1
osresearch commented 4 years ago

This is compiling with gcc (Ubuntu 7.5.0-3ubuntu1~18.04) 7.5.0

ecsv commented 4 years ago

@osresearch Please test with a5300c4949b8d4de2d34bedfaed66793f48ec948

osresearch commented 4 years ago

Manually testing on Ubuntu 20.04 produces a 64KB executable with this change.

However, I'm using my fork #27 that has a simple makefile since there seems to be little reason to require meson and ninja. The fork also adds a test for the output size and a github CI action to build the binary. The Ubuntu 18.04 meson package is still 0.45.1, so the mainline branch doesn't work on github's ubuntu-latest builder.