Skip to contentSkip to conversation

Added stage2 ldscripts

PATCH New Thierry Bultel 2 participants 7 messages Nov 20, 2013 – Apr 20, 2014

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Added stage2 ldscripts

When building stage2 with binutils >= 2.19.1, grub says it is corrupted I have not tried to downgrade binutils to that version, since buildroot offers 2.20.1 as oldest. The issue was reproduced with 2.23.2.

The following patch is clearly not mine.
I have found it at that location https://dev.openwrt.org/ticket/10444
where the issue is described, and the patch offered.

Successfully tested with an iso image in kvm, that else would hang on "Loading stage2 ..."

---
 boot/grub/grub.500-add-stage2-ldscripts.patch |   58 +++++++++++++++++++++++++
 1 files changed, 58 insertions(+), 0 deletions(-)
 create mode 100644 boot/grub/grub.500-add-stage2-ldscripts.patch
boot/grub/grub.500-add-stage2-ldscripts.patch new file +58 -0
new file mode 100644
index 0000000..e940daf
@@ -0,0 +1,58 @@
+diff -Nru grub-0.97.orig/stage2/Makefile.am grub-0.97/stage2/Makefile.am
+--- grub-0.97.orig/stage2/Makefile.am	2013-11-20 23:06:38.770592458 +0100
++++ grub-0.97/stage2/Makefile.am	2013-11-20 23:14:15.296535523 +0100
+@@ -55,7 +55,7 @@
+ endif
+ MOSTLYCLEANFILES = $(noinst_PROGRAMS)
+ 
+-PRE_STAGE2_LINK = -nostdlib -Wl,-N -Wl,-Ttext -Wl,8200
++PRE_STAGE2_LINK = -nostdlib -Wl,-N -Wl,-Tstage2.ldscripts 
+ START_LINK = -nostdlib -Wl,-N -Wl,-Ttext -Wl,8000
+ NBLOADER_LINK = -nostdlib -Wl,-N -Wl,-Ttext -Wl,0
+ PXELOADER_LINK = -nostdlib -Wl,-N -Wl,-Ttext -Wl,7C00
+diff -Nru grub-0.97.orig/stage2/Makefile.in grub-0.97/stage2/Makefile.in
+--- grub-0.97.orig/stage2/Makefile.in	2013-11-20 23:06:38.770592458 +0100
++++ grub-0.97/stage2/Makefile.in	2013-11-20 23:14:33.279985473 +0100
+@@ -470,7 +470,7 @@
+ @DISKLESS_SUPPORT_FALSE at noinst_DATA = pre_stage2 start start_eltorito
+ @DISKLESS_SUPPORT_TRUE at noinst_DATA = pre_stage2 start start_eltorito nbloader pxeloader diskless
+ MOSTLYCLEANFILES = $(noinst_PROGRAMS)
+-PRE_STAGE2_LINK = -nostdlib -Wl,-N -Wl,-Ttext -Wl,8200
++PRE_STAGE2_LINK = -nostdlib -Wl,-N -Wl,-Tstage2.ldscripts 
+ START_LINK = -nostdlib -Wl,-N -Wl,-Ttext -Wl,8000
+ NBLOADER_LINK = -nostdlib -Wl,-N -Wl,-Ttext -Wl,0
+ PXELOADER_LINK = -nostdlib -Wl,-N -Wl,-Ttext -Wl,7C00
+diff -Nru grub-0.97.orig/stage2/stage2.ldscripts grub-0.97/stage2/stage2.ldscripts
+--- grub-0.97.orig/stage2/stage2.ldscripts	1970-01-01 01:00:00.000000000 +0100
++++ grub-0.97/stage2/stage2.ldscripts	2013-11-20 23:14:51.282622012 +0100
+@@ -0,0 +1,30 @@
++/* Script for -N: mix text and data on same page; don't align data */ 
++OUTPUT_FORMAT("elf32-i386", "elf32-i386", 
++             "elf32-i386") 
++OUTPUT_ARCH(i386) 
++ENTRY(_start) 
++SECTIONS 
++{ 
++  . = 0x8200; 
++  .text           : 
++  { 
++    _start = .; 
++    *(.text .text.* ) 
++  } 
++  .rodata         : { *(.rodata .rodata.* ) } 
++  /* Adjust the address for the data segment.  We want to adjust up to 
++     the same address within the page on the next page up.  */ 
++  . = .; 
++  .data           : { *(.data .data.* ) } 
++  __bss_start = .; 
++  .bss            : 
++  { 
++   *(.bss .bss.* ) 
++   *(COMMON) 
++   . = ALIGN(. != 0 ? 32 / 8 : 1); 
++  } 
++  . = ALIGN(32 / 8); 
++  . = ALIGN(32 / 8); 
++  _end = .; PROVIDE (end = .); 
++  .comment       0 : { *(.comment) } 
++} 
Signature · 1 line
1.7.1
#1 lore raw

PATCH 1/1 Added stage2 ldscripts

Dear Thierry Bultel,

Quoted 8 lines · Thierry Bultel

When building stage2 with binutils >= 2.19.1, grub says it is corrupted I have not tried to downgrade binutils to that version, since buildroot offers 2.20.1 as oldest. The issue was reproduced with 2.23.2.

The following patch is clearly not mine.
I have found it at that location https://dev.openwrt.org/ticket/10444
where the issue is described, and the patch offered.

Quoted 8 lines

Successfully tested with an iso image in kvm, that else would hang on "Loading stage2 ..."

---
 boot/grub/grub.500-add-stage2-ldscripts.patch |   58 +++++++++++++++++++++++++
 1 files changed, 58 insertions(+), 0 deletions(-)
 create mode 100644 boot/grub/grub.500-add-stage2-ldscripts.patch

This is weird, because I've built and run grub with the CodeSourcery x86 toolchain, and the Buildroot toolchain (while testing my
http://lists.busybox.net/pipermail/buildroot/2013-November/082351.html
patch series), and it was just working fine.

Note however that
http://lists.busybox.net/pipermail/buildroot/2013-November/082365.html
makes a number of changes in the CFLAGS used to build Grub.

I've just pushed this branch (rebased on top of master) at:

http://git.free-electrons.com/users/thomas-petazzoni/buildroot/log/?h=x86-stuff

Could you try this branch and see if it fixes the problem for you?

Thanks a lot!

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
#2 lore raw

PATCH 1/1 Added stage2 ldscripts

Le 21/11/2013 09:13, Thomas Petazzoni a ?crit :

Quoted 20 lines

Dear Thierry Bultel,

Quoted 8 lines · Thierry Bultel

When building stage2 with binutils >= 2.19.1, grub says it is corrupted I have not tried to downgrade binutils to that version, since buildroot offers 2.20.1 as oldest. The issue was reproduced with 2.23.2.

The following patch is clearly not mine.
I have found it at that location https://dev.openwrt.org/ticket/10444
where the issue is described, and the patch offered.

Quoted 8 lines

Successfully tested with an iso image in kvm, that else would hang on "Loading stage2 ..."

---
  boot/grub/grub.500-add-stage2-ldscripts.patch |   58 +++++++++++++++++++++++++
  1 files changed, 58 insertions(+), 0 deletions(-)

create mode 100644 boot/grub/grub.500-add-stage2-ldscripts.patch

Quoted 5 lines

This is weird, because I've built and run grub with the CodeSourcery x86 toolchain, and the Buildroot toolchain (while testing my
http://lists.busybox.net/pipermail/buildroot/2013-November/082351.html
patch series), and it was just working fine.

FYI my configuration uses Buildroot toolchain/binutils 2.23.2/gcc-4.7.x

Quoted 9 lines

Note however that
http://lists.busybox.net/pipermail/buildroot/2013-November/082365.html
makes a number of changes in the CFLAGS used to build Grub.

I've just pushed this branch (rebased on top of master) at:

http://git.free-electrons.com/users/thomas-petazzoni/buildroot/log/?h=x86-stuff

Could you try this branch and see if it fixes the problem for you?

I have taken your branch and compiled it. I am testing like this:

sudo kvm -cdrom rootfs.iso9660

which works with upstream + the lscript patch

However, on your branch, the grub menu does not show up, I am only getting the grub minimal prompt. For the moment I cannot figure out why.

So that would mean that stage2 is OK but there is another extra issue.

Thierry

Quoted 5 lines

Thanks a lot!

Thomas

#3 lore raw

PATCH 1/1 Added stage2 ldscripts

Dear Thierry Bultel,

Quoted 10 lines · Thierry Bultel

I have taken your branch and compiled it. I am testing like this:

sudo kvm -cdrom rootfs.iso9660

which works with upstream + the lscript patch

However, on your branch, the grub menu does not show up, I am only getting the grub minimal prompt. For the moment I cannot figure out why.

So that would mean that stage2 is OK but there is another extra issue.

I *believe* this usually means that it can't find the grub configuration file.

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
#4 lore raw

PATCH 1/1 Added stage2 ldscripts

Le 21/11/2013 11:47, Thomas Petazzoni a ?crit :

Quoted 10 lines

Dear Thierry Bultel,

Quoted 6 lines · Thierry Bultel

I have taken your branch and compiled it. I am testing like this:

sudo kvm -cdrom rootfs.iso9660

which works with upstream + the lscript patch

Quoted 7 lines
Quoted 4 lines

However, on your branch, the grub menu does not show up, I am only getting the grub minimal prompt. For the moment I cannot figure out why.

So that would mean that stage2 is OK but there is another extra issue.

I *believe* this usually means that it can't find the grub configuration file.

Yes that's the point. I have attempted to debug:
grub_open fails on /boot/grub/menu.lst

But when I mount my iso image, it is there:

$ ls /mnt/boot/grub/
menu.lst         stage2_eltorito

I finally found out that it is grub does not support the iso9660 filesystem.

I have added it to the list of supported ones and it works. That is a little bit annoying to have to do it manually.

On your branch it is explicitly deselected when configured, whereas it was configured by default on mainstream.

I think it could be could to :
1) Set the supported FS as choices in xconfig
2) Make iso9660 automatically selected when an iso image must be built

Regards
Thierry

Quoted 3 lines

Thomas

#5 lore raw

PATCH 1/1 Added stage2 ldscripts

Dear Thierry Bultel,

Quoted 10 lines · Thierry Bultel

Yes that's the point. I have attempted to debug:
grub_open fails on /boot/grub/menu.lst

But when I mount my iso image, it is there:

$ ls /mnt/boot/grub/
menu.lst         stage2_eltorito

I finally found out that it is grub does not support the iso9660 filesystem.

Aah!

Quoted 8 lines

I have added it to the list of supported ones and it works. That is a little bit annoying to have to do it manually.

On your branch it is explicitly deselected when configured, whereas it was configured by default on mainstream.

I think it could be could to :
1) Set the supported FS as choices in xconfig

Did you realize that such an option exists, and is added by my patch set ? :-)

See:

http://git.free-electrons.com/users/thomas-petazzoni/buildroot/commit/?h=x86-stuff&id=b01db75a6d7165005f9fb069c340f4206160c7f5

which adds the BR2_TARGET_GRUB_FS_SUPPORT option. You simply need to change it from "ext2fs fat" to "ext2fs fat iso9660" and that's it.

Can you confirm that it works for you?

Also, could you share how you build your ISO image with Grub ? I would be interested in adding these details to the Config.in help text, as I did to explain how to create a disk image that has grub installed.

Thanks!

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
#6 lore raw

PATCH 1/1 Added stage2 ldscripts

In reply to Thierry Bultel

Dear Thierry Bultel,

Quoted 8 lines · Thierry Bultel

When building stage2 with binutils >= 2.19.1, grub says it is corrupted I have not tried to downgrade binutils to that version, since buildroot offers 2.20.1 as oldest. The issue was reproduced with 2.23.2.

The following patch is clearly not mine.
I have found it at that location https://dev.openwrt.org/ticket/10444
where the issue is described, and the patch offered.

Quoted 8 lines

Successfully tested with an iso image in kvm, that else would hang on "Loading stage2 ..."

---
 boot/grub/grub.500-add-stage2-ldscripts.patch |   58 +++++++++++++++++++++++++
 1 files changed, 58 insertions(+), 0 deletions(-)
 create mode 100644 boot/grub/grub.500-add-stage2-ldscripts.patch

As our discussion has shown, this patch is in fact not necessary. I've consequently marked it as Rejected in patchwork. Do not hesitate to let me know if you still have unsolved issues with grub.

Thanks,

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com