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