nalika / rpms / grub2

Forked from rpms/grub2 2 years ago
Clone

Blame SOURCES/0225-strip-R-.note.gnu.property-at-more-places.patch

8631a2
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
8631a2
From: Peter Jones <pjones@redhat.com>
8631a2
Date: Fri, 3 Aug 2018 15:07:23 -0400
8631a2
Subject: [PATCH] strip "-R .note.gnu.property" at more places.
8631a2
8631a2
For whatever reason, sometimes I see:
8631a2
8631a2
    lzma_decompress.image:     file format elf32-i386
8631a2
    lzma_decompress.image
8631a2
    architecture: i386, flags 0x00000012:
8631a2
    EXEC_P, HAS_SYMS
8631a2
    start address 0x00008200
8631a2
8631a2
    Program Header:
8631a2
        LOAD off    0x000000c0 vaddr 0x00008200 paddr 0x00008200 align 2**5
8631a2
             filesz 0x00000b10 memsz 0x00000b10 flags rwx
8631a2
        LOAD off    0x00000bd0 vaddr 0x080480b4 paddr 0x080480b4 align 2**2
8631a2
             filesz 0x0000001c memsz 0x0000001c flags r--
8631a2
        NOTE off    0x00000bd0 vaddr 0x080480b4 paddr 0x080480b4 align 2**2
8631a2
             filesz 0x0000001c memsz 0x0000001c flags r--
8631a2
       STACK off    0x00000000 vaddr 0x00000000 paddr 0x00000000 align 2**4
8631a2
             filesz 0x00000000 memsz 0x00000000 flags rw-
8631a2
8631a2
    Sections:
8631a2
    Idx Name          Size      VMA       LMA       File off  Algn
8631a2
      0 .note.gnu.property 0000001c  080480b4  080480b4  00000bd0  2**2
8631a2
                      CONTENTS, ALLOC, LOAD, READONLY, DATA
8631a2
      1 .text         00000b10  00008200  00008200  000000c0  2**5
8631a2
                      CONTENTS, ALLOC, LOAD, CODE
8631a2
    SYMBOL TABLE:
8631a2
    080480b4 l    d  .note.gnu.property	00000000 .note.gnu.property
8631a2
    00008200 l    d  .text	00000000 .text
8631a2
    00000000 l    df *ABS*	00000000 startup_raw.S
8631a2
    ...
8631a2
8631a2
Which just looks wrong no matter what to my eyes (seriously it's at
8631a2
128M? Why?), and when we fail to strip it, we get:
8631a2
8631a2
trillian:~/tmp/f29$ hexdump -C usr/lib/grub/i386-pc/lzma_decompress.img | tail -6
8631a2
00000b00  ff 45 e8 5a 83 c2 02 89  d1 e9 df fe ff ff 66 90  |.E.Z..........f.|
8631a2
00000b10  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
8631a2
*
8631a2
0803feb0  00 00 00 00 04 00 00 00  0c 00 00 00 05 00 00 00  |................|
8631a2
0803fec0  47 4e 55 00 02 00 00 c0  04 00 00 00 03 00 00 00  |GNU.............|
8631a2
0803fed0
8631a2
8631a2
Which is very very much not what we want.
8631a2
8631a2
Cut it out.
8631a2
8631a2
Signed-off-by: Peter Jones <pjones@redhat.com>
8631a2
---
8631a2
 Makefile.am | 2 +-
8631a2
 gentpl.py   | 2 +-
8631a2
 2 files changed, 2 insertions(+), 2 deletions(-)
8631a2
8631a2
diff --git a/Makefile.am b/Makefile.am
f6e916
index c7b0e6a9c..287fff66b 100644
8631a2
--- a/Makefile.am
8631a2
+++ b/Makefile.am
8631a2
@@ -209,7 +209,7 @@ pc-chainloader.elf: $(srcdir)/grub-core/tests/boot/kernel-8086.S $(srcdir)/grub-
8631a2
 	$(TARGET_CC) -o $@ $< -static -DTARGET_CHAINLOADER=1 -DSUCCESSFUL_BOOT_STRING=\"$(SUCCESSFUL_BOOT_STRING)\" -ffreestanding -nostdlib -nostdinc -Wl,--build-id=none -Wl,-N -Wl,-Ttext,0x7c00 -m32
8631a2
 
8631a2
 pc-chainloader.bin: pc-chainloader.elf
8631a2
-	$(TARGET_OBJCOPY) -O binary --strip-unneeded -R .note -R .comment -R .note.gnu.build-id -R .reginfo -R .rel.dyn -R .note.gnu.gold-version $< $@;
8631a2
+	$(TARGET_OBJCOPY) -O binary --strip-unneeded -R .note -R .comment -R .note.gnu.build-id -R .reginfo -R .rel.dyn -R .note.gnu.gold-version -R .note.gnu.property $< $@;
8631a2
 
8631a2
 ntldr.elf: $(srcdir)/grub-core/tests/boot/kernel-8086.S $(srcdir)/grub-core/tests/boot/qemu-shutdown-x86.S
8631a2
 	$(TARGET_CC) -o $@ $< -DTARGET_NTLDR=1 -DSUCCESSFUL_BOOT_STRING=\"$(SUCCESSFUL_BOOT_STRING)\" -static -ffreestanding -nostdlib -nostdinc -Wl,--build-id=none -Wl,-N -Wl,-Ttext,0 -m32
8631a2
diff --git a/gentpl.py b/gentpl.py
f6e916
index 1e4635f44..d662c305f 100644
8631a2
--- a/gentpl.py
8631a2
+++ b/gentpl.py
8631a2
@@ -776,7 +776,7 @@ def image(defn, platform):
8631a2
 if test x$(TARGET_APPLE_LINKER) = x1; then \
8631a2
   $(MACHO2IMG) $< $@; \
8631a2
 else \
8631a2
-  $(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 .ARM.exidx $< $@; \
8631a2
+  $(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 .ARM.exidx -R .note.gnu.property $< $@; \
8631a2
 fi
8631a2
 """)
8631a2