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

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