From 2daa23f4a48234685a5f6eadea97a02ec837e755 Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Sat, 24 Apr 2010 19:15:51 +0100 Subject: [PATCH 1/1] [build] Generate random build identifier Randomly generate a 32-bit build identifier that can be used to identify identical gPXE ROMs when multiple such ROMs are present in a system (e.g. when a multi-function NIC exposes the same gPXE ROM image via each function's expansion ROM BAR). Signed-off-by: Michael Brown Signed-off-by: Stefan Hajnoczi --- src/Makefile.housekeeping | 9 +++++++-- src/arch/i386/prefix/romprefix.S | 3 +++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/Makefile.housekeeping b/src/Makefile.housekeeping index 637a6aa3..fc5402e8 100644 --- a/src/Makefile.housekeeping +++ b/src/Makefile.housekeeping @@ -688,13 +688,18 @@ $(BLIB) : $(BLIB_OBJS) $(BLIB_LIST) $(MAKEDEPS) $(Q)$(RANLIB) $@ blib : $(BLIB) +# Command to generate build ID. Must be unique for each $(BIN)/%.tmp, +# even within the same build run. +# +BUILD_ID_CMD := perl -e 'printf "0x%08x", int ( rand ( 0xffffffff ) );' + # Build an intermediate object file from the objects required for the # specified target. # -$(BIN)/%.tmp : $(BLIB) $(MAKEDEPS) $(LDSCRIPT) +$(BIN)/%.tmp : $(BLIB) $(MAKEDEPS) $(LDSCRIPT) $(QM)$(ECHO) " [LD] $@" $(Q)$(LD) $(LDFLAGS) -T $(LDSCRIPT) $(TGT_LD_FLAGS) $(BLIB) -o $@ \ - -Map $(BIN)/$*.tmp.map + --defsym _build_id=`$(BUILD_ID_CMD)` -Map $(BIN)/$*.tmp.map $(Q)$(OBJDUMP) -ht $@ | $(SORTOBJDUMP) >> $(BIN)/$*.tmp.map # Keep intermediate object file (useful for debugging) diff --git a/src/arch/i386/prefix/romprefix.S b/src/arch/i386/prefix/romprefix.S index 21da1633..7f22a70f 100644 --- a/src/arch/i386/prefix/romprefix.S +++ b/src/arch/i386/prefix/romprefix.S @@ -52,6 +52,9 @@ checksum: .long 0 .previous +build_id: + .long _build_id /* Randomly-generated build ID */ + pciheader: .ascii "PCIR" /* Signature */ .word pci_vendor_id /* Vendor identification */ -- 2.17.1