Skip to contentSkip to conversation

Preserve build IDs

PATCH In review Lubomir Kundrak 3 participants 6 messages Apr 14, 2008 – Apr 17, 2008

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Preserve build IDs

This will make Fedora packagers have good sleep. I think we discussed this already on the list. Rationale behind disabling build-ids completely was that it caused images to grow a lot. Correct solution is to disable it from images only and let it exists in elf files for debugging purposes.

2008-04-15 Lubomir Kundrak <[email protected]>

* aclocal.m4 (grub_PROG_OBJCOPY_ABSOLUTE): take only .text section into account, newer toolchains generate unique build ids
* configure.ac: remove the test for --build-id=none acceptance, we want build ids to bre preserved
* genmk.rb: add -R .note.gnu.build-id to objcopy, so build id far from other sections don't cause the raw binary images grow size

Signature · 1 line
Lubomir Kundrak (Red Hat Security Response Team)
aclocal.m4 +1 -1
diff -urp grub-1.96.orig/aclocal.m4 grub-1.96/aclocal.m4
@@ -61,7 +61,7 @@ for link_addr in 2000 8000 7C00; do
   else
     AC_MSG_ERROR([${CC-cc} cannot link at address $link_addr])
   fi
-  if AC_TRY_COMMAND([${OBJCOPY-objcopy} -O binary conftest.exec conftest]); then :
+  if AC_TRY_COMMAND([${OBJCOPY-objcopy} --only-section=.text -O binary conftest.exec conftest]); then :
   else
     AC_MSG_ERROR([${OBJCOPY-objcopy} cannot create binary files])
   fi
configure.ac +0 -10
diff -urp grub-1.96.orig/configure.ac grub-1.96/configure.ac
@@ -237,16 +237,6 @@ if test "x$target_m32" = x1; then
   TARGET_LDFLAGS="$TARGET_LDFLAGS -m32"
 fi
 
-AC_MSG_CHECKING([whether the linker accepts `--build-id=none'])
-save_LDFLAGS="$LDFLAGS"
-LDFLAGS="$LDFLAGS -Wl,--build-id=none"
-AC_TRY_LINK(, , build_id_flag=yes, build_id_flag=no)
-AC_MSG_RESULT([$build_id_flag])
-LDFLAGS="$save_LDFLAGS"
-if test "x$build_id_flag" = xyes; then
-  TARGET_LDFLAGS="$TARGET_LDFLAGS -Wl,--build-id=none"
-fi
-
 #
 # Compiler features.
 #
genmk.rb +1 -1
diff -urp grub-1.96.orig/genmk.rb grub-1.96/genmk.rb
@@ -57,7 +57,7 @@ class Image
 MOSTLYCLEANFILES += #{deps_str}
 
 #{@name}: #{exe}
-	$(OBJCOPY) -O binary -R .note -R .comment $< $@
+	$(OBJCOPY) -O binary -R .note -R .comment -R .note.gnu.build-id $< $@
 
 #{exe}: #{objs_str}
 	$(TARGET_CC) -o $@ $^ $(TARGET_LDFLAGS) $(#{prefix}_LDFLAGS)
#1 lore raw
Quoted 8 lines · Lubomir Kundrak

This will make Fedora packagers have good sleep. I think we discussed this already on the list. Rationale behind disabling build-ids completely was that it caused images to grow a lot. Correct solution is to disable it from images only and let it exists in elf files for debugging purposes.

2008-04-15 Lubomir Kundrak <[email protected]>

Quoted 7 lines

* aclocal.m4 (grub_PROG_OBJCOPY_ABSOLUTE): take only .text section into account, newer toolchains generate unique build ids
* configure.ac: remove the test for --build-id=none acceptance, we want build ids to bre preserved
* genmk.rb: add -R .note.gnu.build-id to objcopy, so build id far from other sections don't cause the raw binary images grow size

Looks good to me. Pavel will probably know better though.

Signature · 5 lines
Robert Millan

<GPLv2> I know my rights; I want my phone call!
<DRM> What use is a phone call… if you are unable to speak?
(as seen on /.)
#2 lore raw
Quoted 17 lines · Robert Millan
Quoted 8 lines · Lubomir Kundrak

This will make Fedora packagers have good sleep. I think we discussed this already on the list. Rationale behind disabling build-ids completely was that it caused images to grow a lot. Correct solution is to disable it from images only and let it exists in elf files for debugging purposes.

2008-04-15 Lubomir Kundrak <[email protected]>

Quoted 7 lines

* aclocal.m4 (grub_PROG_OBJCOPY_ABSOLUTE): take only .text section into account, newer toolchains generate unique build ids
* configure.ac: remove the test for --build-id=none acceptance, we want build ids to bre preserved
* genmk.rb: add -R .note.gnu.build-id to objcopy, so build id far from other sections don't cause the raw binary images grow size

Quoted 1 line

Looks good to me. Pavel will probably know better though.

Looks good to me too. There is a bug in objcopy if it's used without stripping the build ID. But if we are stripping it, there should be no problem with it.

Signature · 2 lines
Regards,
Pavel Roskin
#3 lore raw
Quoted 18 lines · Pavel Roskin
Quoted 17 lines · Robert Millan
Quoted 15 lines · Lubomir Kundrak

This will make Fedora packagers have good sleep. I think we discussed this already on the list. Rationale behind disabling build-ids completely was that it caused images to grow a lot. Correct solution is to disable it from images only and let it exists in elf files for debugging purposes.

2008-04-15 Lubomir Kundrak <[email protected]>

* aclocal.m4 (grub_PROG_OBJCOPY_ABSOLUTE): take only .text section into account, newer toolchains generate unique build ids
* configure.ac: remove the test for --build-id=none acceptance, we want build ids to bre preserved
* genmk.rb: add -R .note.gnu.build-id to objcopy, so build id far from other sections don't cause the raw binary images grow size

Quoted 5 lines
Quoted 1 line

Looks good to me. Pavel will probably know better though.

Looks good to me too. There is a bug in objcopy if it's used without stripping the build ID. But if we are stripping it, there should be no problem with it.

Actually that turned to not being a bug, if I recall correctly. It was just that in plain flat binary files there's really no way to express emptiness other by padding with zeroes.

However this is irrelevant since we no longer include that in the plain binary files. There's little use of it anyways, as it would not be possible to look it up in the file, given it resides in own section in ELF, and plain binaries really have no sections.

Thanks,

Signature · 1 line
Lubomir Kundrak (Red Hat Security Response Team)
#4 lore raw
Quoted 3 lines · Lubomir Kundrak

Actually that turned to not being a bug, if I recall correctly. It was just that in plain flat binary files there's really no way to express emptiness other by padding with zeroes.

I don't want to start a protracted discussion about binutils here, but it's a bug in my opinion. objcopy is supposed to understand the optional role of build ID and strip it if it cannot be presented in the output as a build ID, rather than convert is to piece of binary data followed by megabytes of "emptiness".

Quoted 4 lines

However this is irrelevant since we no longer include that in the plain binary files. There's little use of it anyways, as it would not be possible to look it up in the file, given it resides in own section in ELF, and plain binaries really have no sections.

Agreed.

Signature · 2 lines
Regards,
Pavel Roskin
#5 lore raw
In reply to Pavel Roskin
Quoted 19 lines · Pavel Roskin
Quoted 17 lines · Robert Millan
Quoted 15 lines · Lubomir Kundrak

This will make Fedora packagers have good sleep. I think we discussed this already on the list. Rationale behind disabling build-ids completely was that it caused images to grow a lot. Correct solution is to disable it from images only and let it exists in elf files for debugging purposes.

2008-04-15 Lubomir Kundrak <[email protected]>

* aclocal.m4 (grub_PROG_OBJCOPY_ABSOLUTE): take only .text section into account, newer toolchains generate unique build ids
* configure.ac: remove the test for --build-id=none acceptance, we want build ids to bre preserved
* genmk.rb: add -R .note.gnu.build-id to objcopy, so build id far from other sections don't cause the raw binary images grow size

Quoted 5 lines
Quoted 1 line

Looks good to me. Pavel will probably know better though.

Looks good to me too. There is a bug in objcopy if it's used without stripping the build ID. But if we are stripping it, there should be no problem with it.

Ok, I checked that in.

Signature · 5 lines
Robert Millan

<GPLv2> I know my rights; I want my phone call!
<DRM> What use is a phone call… if you are unable to speak?
(as seen on /.)