Browse Source

[build] Generate random build identifier

Randomly generate a 32-bit build identifier that can be used to
identify identical iPXE ROMs when multiple such ROMs are present in a
system (e.g. when a multi-function NIC exposes the same iPXE ROM image
via each function's expansion ROM BAR).

Signed-off-by: Michael Brown <mcb30@ipxe.org>
tags/v1.20.1
Michael Brown 14 years ago
parent
commit
58f6e55362
2 changed files with 10 additions and 2 deletions
  1. 7
    2
      src/Makefile.housekeeping
  2. 3
    0
      src/arch/i386/prefix/romprefix.S

+ 7
- 2
src/Makefile.housekeeping View File

@@ -686,13 +686,18 @@ $(BLIB) : $(BLIB_OBJS) $(BLIB_LIST) $(MAKEDEPS)
686 686
 	$(Q)$(RANLIB) $@
687 687
 blib : $(BLIB)
688 688
 
689
+# Command to generate build ID.  Must be unique for each $(BIN)/%.tmp,
690
+# even within the same build run.
691
+#
692
+BUILD_ID_CMD	:= perl -e 'printf "0x%08x", int ( rand ( 0xffffffff ) );'
693
+
689 694
 # Build an intermediate object file from the objects required for the
690 695
 # specified target.
691 696
 #
692
-$(BIN)/%.tmp : $(BLIB) $(MAKEDEPS) $(LDSCRIPT) 
697
+$(BIN)/%.tmp : $(BLIB) $(MAKEDEPS) $(LDSCRIPT)
693 698
 	$(QM)$(ECHO) "  [LD] $@"
694 699
 	$(Q)$(LD) $(LDFLAGS) -T $(LDSCRIPT) $(TGT_LD_FLAGS) $(BLIB) -o $@ \
695
-		-Map $(BIN)/$*.tmp.map
700
+		--defsym _build_id=`$(BUILD_ID_CMD)` -Map $(BIN)/$*.tmp.map
696 701
 	$(Q)$(OBJDUMP) -ht $@ | $(SORTOBJDUMP) >> $(BIN)/$*.tmp.map
697 702
 
698 703
 # Keep intermediate object file (useful for debugging)

+ 3
- 0
src/arch/i386/prefix/romprefix.S View File

@@ -52,6 +52,9 @@ checksum:
52 52
 	.long	0
53 53
 	.previous
54 54
 
55
+build_id:
56
+	.long	_build_id		/* Randomly-generated build ID */
57
+
55 58
 pciheader:
56 59
 	.ascii	"PCIR"			/* Signature */
57 60
 	.word	pci_vendor_id		/* Vendor identification */ 

Loading…
Cancel
Save