Skip to contentSkip to conversation

Grub2 clang MBR image fix

PATCH In review Nicholas Vinson 3 participants 4 messages Jan 13, 2023 – Jan 17, 2023

lore
Share & tools
lore
#0 lore raw

cover Grub2 clang MBR image fix

When building grub, the files boot.img and diskboot.img are generated from ELF reference images and have the expectation that they will be 512 bytes inside each. However, when GRUB is built with clang, these files become bigger than 512-bytes because the name of the ELF interpreter is appended to each image due to Clang creating a '.interp' section in the ELF reference image.

This patch corrects that issue by updating the objcopy calls so the '.interp' section is not included when extracting the code from the ELF reference images.

Nicholas Vinson (1):
gentpl.py: Remove .interp section from .img files.

 gentpl.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Signature · 1 line
2.39.0
#1 lore raw

PATCH 1/1 gentpl.py: Remove .interp section from .img files.

Whn building .img files, a .interp section from the .image files will sometimes be copied into the .img file. This additional section pushes the .img file beyond the 512-byte limit and causes grub-install to fail to run for i386-pc platforms.

---
 gentpl.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
gentpl.py +1 -1
index 9f51e4fb6..88abe5b0a 100644
@@ -766,7 +766,7 @@ def image(defn, platform):
 if test x$(TARGET_APPLE_LINKER) = x1; then \
   $(MACHO2IMG) $< $@; \
 else \
-  $(TARGET_OBJCOPY) $(""" + cname(defn) + """_OBJCOPYFLAGS) --strip-unneeded -R .note -R .comment -R .note.gnu.build-id -R .MIPS.abiflags -R .reginfo -R .rel.dyn -R .note.gnu.gold-version -R .note.gnu.property -R .ARM.exidx $< $@; \
+  $(TARGET_OBJCOPY) $(""" + cname(defn) + """_OBJCOPYFLAGS) --strip-unneeded -R .note -R .comment -R .note.gnu.build-id -R .MIPS.abiflags -R .reginfo -R .rel.dyn -R .note.gnu.gold-version -R .note.gnu.property -R .ARM.exidx -R .interp $< $@; \
 fi
 """)
 
Signature · 1 line
2.39.0
#2 lore raw

Re: [PATCH 1/1] gentpl.py: Remove .interp section from .img files.

LGTM

Quoted 38 lines · Nicholas Vinson

Whn building .img files, a .interp section from the .image files will sometimes be copied into the .img file. This additional section pushes the .img file beyond the 512-byte limit and causes grub-install to fail to run for i386-pc platforms.

---
 gentpl.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
gentpl.py +0 -2
index 9f51e4fb6..88abe5b0a 100644
@@ -766,7 +766,7 @@ def image(defn, platform):
 if test x$(TARGET_APPLE_LINKER) = x1; then \
   $(MACHO2IMG) $< $@; \
 else \
-  $(TARGET_OBJCOPY) $(""" + cname(defn) + """_OBJCOPYFLAGS)
--strip-unneeded -R .note -R .comment -R .note.gnu.build-id -R

.MIPS.abiflags -R .reginfo -R .rel.dyn -R .note.gnu.gold-version -R .note.gnu.property -R .ARM.exidx $< $@; \
+ $(TARGET_OBJCOPY) $(""" + cname(defn) + """_OBJCOPYFLAGS) --strip-unneeded -R .note -R .comment -R .note.gnu.build-id -R .MIPS.abiflags -R .reginfo -R .rel.dyn -R .note.gnu.gold-version -R .note.gnu.property -R .ARM.exidx -R .interp $< $@; \
fi
""")

--
2.39.0

_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel

Signature · 2 lines
Regards
Vladimir 'phcoder' Serbinenko
Reviewed-by on v1 1/1
#3 lore raw

Re: [PATCH 1/1] gentpl.py: Remove .interp section from .img files.

In reply to Nicholas Vinson
Quoted 6 lines · Nicholas Vinson

Whn building .img files, a .interp section from the .image files will sometimes be copied into the .img file. This additional section pushes the .img file beyond the 512-byte limit and causes grub-install to fail to run for i386-pc platforms.

Daniel