bugGNU GRUB - Bugs: bug #34539, 1.99: grub2 built with gold linker...

 
 

You are not allowed to post comments on this tracker with your current authentication level.

bug #34539: 1.99: grub2 built with gold linker doesn't even start

Submitter:  Arkadiusz Miskiewicz <arekm>
Submitted:  Thu 13 Oct 2011 06:49:28 AM UTC
   
 
Category:  Compilation Severity:  Major
Priority:  5 - Normal Item Group:  Software Error
Status:  Fixed Privacy:  Public
Assigned to:  None Originator Name: 
Open/Closed:  Closed Release:  other
Release:  Reproducibility:  Every Time
Planned Release:  None

Sat 02 Nov 2013 06:15:46 PM UTC, comment #5: 

CFLAGS="$TARGET_CFLAGS -nostdlib ${TARGET_IMG_LDFLAGS_AC} ${TARGET_IMG_BASE_LDOPT},8000 -Wl,--defsym,___main=0x8100" doesn't matter as resulting binary is never executed. I changed it nevertheless for consistency.
Recent gold doesn't have this bug. I added a check to grub-mkimagexx.c to reject miscompiled images.

Vladimir Serbinenko <phcoder>
Group administrator
Wed 02 Jan 2013 02:43:07 AM UTC, comment #4: 

The correct upstream reference is:

  http://sourceware.org/bugzilla/show_bug.cgi?id=14196

Colin Watson <cjwatson>
Group Member
Wed 02 Jan 2013 02:25:06 AM UTC, comment #3: 

Mike: I'm not so sure.  The bug you mention involves gold entirely rejecting 7C00 but accepting 0x7C00; the bug Vladimir describes (and which I can reproduce, although I'm not certain where it resides) involves gold accepting 0x7C00 but apparently adding 0x1000 to it.

Colin Watson <cjwatson>
Group Member
Mon 22 Oct 2012 04:33:25 AM UTC, comment #2: 

i think the latest comment contains typos.  gold will use the wrong address if you specify "-Wl,-Ttext,8200" (namely, it'll use 0x2008 and not 0x8200).  it will work fine if you prefix the address with a hex value like "-Wl,-Ttext,0x8200".

$ gcc -o 1.img -ffreestanding -Wl,-Ttext,8200 1.S -nostdlib -m32
$ readelf -S 1.img | grep text
  [ 1] .text             PROGBITS        00002008 001008 000000 00  AX  0   0  4
$ gcc -o 1.img -ffreestanding -Wl,-Ttext,0x8200 1.S -nostdlib -m32
$ readelf -S 1.img | grep text
  [ 1] .text             PROGBITS        00008200 000200 000000 00  AX  0   0  4

upstream bug:
http://sourceware.org/bugzilla/show_bug.cgi?id=14187

it's trivial to workaround in grub2: add a 0x prefix to addresses with the -Ttext flag.  a quick grep shows at least:
configure.ac:      CFLAGS="$TARGET_CFLAGS -nostdlib ${TARGET_IMG_LDFLAGS_AC} ${TARGET_IMG_BASE_LDOPT},8000 -Wl,--defsym,___main=0x8100"

Mike Frysinger <vapier>
Sat 10 Mar 2012 03:49:25 PM UTC, comment #1: 

This seems to be gold bug. Namely the minimal testcase is:
gcc -o 1.img -ffreestanding -Wl,-Ttext,0x8200 1.S -nostdlib -m32
The resulting file has .text at 9200 and not 8200
1.S:
        .text

        .globl  _start
_start:

Vladimir Serbinenko <phcoder>
Group administrator
Thu 13 Oct 2011 06:49:28 AM UTC, original submission:  

If you build grub2 1.99 (1.97, 1.98 also tested) with gold linker:


$ ld --version
GNU gold (Linux/GNU Binutils 2.21.53.0.2.20110804) 1.11

instead of old ld.bfd then your grub won't even show its menu when booting. Just black screen.

 objdump -D -b binary -mi386 -Maddr16,data16 boot.img
on boot.img built with gold and ld.bfd shows differencies which are probably cause of the problem:


$ diff -u x ~/obj-good.txt
--- x   2011-10-13 08:39:21.224700551 +0200
+++ /home/users/arekm/obj-good.txt      2011-10-12 22:30:36.724055586 +0200
@@ -1,5 +1,5 @@
 
-boot.img:     file format binary
+/boot/grub/boot.img:     file format binary
 
 
 Disassembly of section .data:
@@ -20,20 +20,20 @@
   6d:  f6 c2 70                test   $0x70,%dl
   70:  74 02                   je     0x74
   72:  b2 80                   mov    $0x80,%dl
-  74:  ea 79 8c 00 00          ljmp   $0x0,$0x8c79
+  74:  ea 79 7c 00 00          ljmp   $0x0,$0x7c79
   79:  31 c0                   xor    %ax,%ax
   7b:  8e d8                   mov    %ax,%ds
   7d:  8e d0                   mov    %ax,%ss
   7f:  bc 00 20                mov    $0x2000,%sp
   82:  fb                      sti   
-  83:  a0 64 8c                mov    0x8c64,%al
+  83:  a0 64 7c                mov    0x7c64,%al
   86:  3c ff                   cmp    $0xff,%al
   88:  74 02                   je     0x8c
   8a:  88 c2                   mov    %al,%dl
   8c:  52                      push   %dx
-  8d:  be 80 8d                mov    $0x8d80,%si
+  8d:  be 80 7d                mov    $0x7d80,%si
   90:  e8 17 01                call   0x1aa
-  93:  be 05 8c                mov    $0x8c05,%si
+  93:  be 05 7c                mov    $0x7c05,%si
   96:  b4 41                   mov    $0x41,%ah
   98:  bb aa 55                mov    $0x55aa,%bx
   9b:  cd 13                   int    $0x13
@@ -50,9 +50,9 @@
   b2:  88 44 ff                mov    %al,-0x1(%si)
   b5:  89 44 02                mov    %ax,0x2(%si)
   b8:  c7 04 10 00             movw   $0x10,(%si)
-  bc:  66 8b 1e 5c 8c          mov    -0x73a4,%ebx
+  bc:  66 8b 1e 5c 7c          mov    0x7c5c,%ebx
   c1:  66 89 5c 08             mov    %ebx,0x8(%si)
-  c5:  66 8b 1e 60 8c          mov    -0x73a0,%ebx
+  c5:  66 8b 1e 60 7c          mov    0x7c60,%ebx
   ca:  66 89 5c 0c             mov    %ebx,0xc(%si)
   ce:  c7 44 06 00 70          movw   $0x7000,0x6(%si)
   d3:  b4 42                   mov    $0x42,%ah
@@ -65,7 +65,7 @@
   e2:  73 0d                   jae    0xf1
   e4:  f6 c2 80                test   $0x80,%dl
   e7:  0f 84 d8 00             je     0x1c3
-  eb:  be 8b 8d                mov    $0x8d8b,%si
+  eb:  be 8b 7d                mov    $0x7d8b,%si
   ee:  e9 82 00                jmp    0x173
   f1:  66 0f b6 c6             movzbl %dh,%eax
   f5:  88 64 ff                mov    %ah,-0x1(%si)
@@ -80,10 +80,10 @@
  10b:  0f b6 c2                movzbw %dl,%ax
  10e:  c0 e8 02                shr    $0x2,%al
  111:  66 89 04                mov    %eax,(%si)
- 114:  66 a1 60 8c             mov    0x8c60,%eax
+ 114:  66 a1 60 7c             mov    0x7c60,%eax
  118:  66 09 c0                or     %eax,%eax
  11b:  75 4e                   jne    0x16b
- 11d:  66 a1 5c 8c             mov    0x8c5c,%eax
+ 11d:  66 a1 5c 7c             mov    0x7c5c,%eax
  121:  66 31 d2                xor    %edx,%edx
  124:  66 f7 34                divl   (%si)
  127:  88 d1                   mov    %dl,%cl
@@ -117,12 +117,12 @@
  163:  f3 a5                   rep movsw %ds:(%si),%es:(%di)
  165:  1f                      pop    %ds
  166:  61                      popa
- 167:  ff 26 5a 8c             jmp    *-0x73a6
- 16b:  be 86 8d                mov    $0x8d86,%si
+ 167:  ff 26 5a 7c             jmp    *0x7c5a
+ 16b:  be 86 7d                mov    $0x7d86,%si
  16e:  eb 03                   jmp    0x173
- 170:  be 95 8d                mov    $0x8d95,%si
+ 170:  be 95 7d                mov    $0x7d95,%si
  173:  e8 34 00                call   0x1aa
- 176:  be 9a 8d                mov    $0x8d9a,%si
+ 176:  be 9a 7d                mov    $0x7d9a,%si
  179:  e8 2e 00                call   0x1aa
  17c:  cd 18                   int    $0x18
  17e:  eb fe                   jmp    0x17e
@@ -157,14 +157,14 @@
  1bc:  00 00                   add    %al,(%bx,%si)
  1be:  24 12                   and    $0x12,%al
  1c0:  0f 09                   wbinvd
- 1c2:  00 be bd 8d             add    %bh,-0x7243(%bp)
+ 1c2:  00 be bd 7d             add    %bh,0x7dbd(%bp)
  1c6:  31 c0                   xor    %ax,%ax
  1c8:  cd 13                   int    $0x13
  1ca:  46                      inc    %si
  1cb:  8a 0c                   mov    (%si),%cl
  1cd:  80 f9 00                cmp    $0x0,%cl
  1d0:  75 0f                   jne    0x1e1
- 1d2:  be da 8d                mov    $0x8dda,%si
+ 1d2:  be da 7d                mov    $0x7dda,%si
  1d5:  e8 d2 ff                call   0x1aa
  1d8:  eb 9c                   jmp    0x176
  1da:  46                      inc    %si

Arkadiusz Miskiewicz <arekm>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by cjwatson (Posted a comment)
  • -email is unavailable- added by vapier (Posted a comment)
  • -email is unavailable- added by heirecka
  • -email is unavailable- added by ridikulus_rat
  • -email is unavailable- added by phcoder (Posted a comment)
  • -email is unavailable- added by arekm (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

     

    Follow 4 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2013-11-02 phcoder StatusNone Fixed
        Open/ClosedOpen Closed
    2012-08-08 heirecka Carbon-Copy- Added heirecka
    2012-04-20 ridikulus_rat Carbon-Copy- Added ridikulus_rat

    Back to the top

    Powered by Savane 3.13-f8d8.
    Corresponding source code