395898
diff --git a/doc/icedax/tracknames.pl b/doc/icedax/tracknames.pl
395898
old mode 100755
395898
new mode 100644
395898
index 09f0fcf..801b89e
395898
--- a/doc/icedax/tracknames.pl
395898
+++ b/doc/icedax/tracknames.pl
395898
@@ -1,4 +1,4 @@
395898
-#!/usr/local/bin/perl 
395898
+#!/usr/bin/perl 
395898
 # A quick perl hack to get rename files pulled in with icedax.
395898
 # by billo@billo.com
395898
 #
395898
diff --git a/genisoimage/eltorito.c b/genisoimage/eltorito.c
395898
index b97bdf1..5d7c2d1 100644
395898
--- a/genisoimage/eltorito.c
395898
+++ b/genisoimage/eltorito.c
395898
@@ -59,7 +59,7 @@ static	void	get_torito_desc(struct eltorito_boot_descriptor *boot_desc);
395898
 static	void	fill_boot_desc(struct eltorito_defaultboot_entry *boot_desc_entry,
395898
 										struct eltorito_boot_entry_info *boot_entry);
395898
 void	get_boot_entry(void);
395898
-void	new_boot_entry(void);
395898
+void	new_boot_entry();
395898
 static	int	tvd_write(FILE *outfile);
395898
 
395898
 
395898
@@ -283,6 +283,7 @@ get_torito_desc(struct eltorito_boot_descriptor *boot_desc)
395898
 	int			i;
395898
 	int			offset;
395898
 	struct eltorito_defaultboot_entry boot_desc_record;
395898
+	struct eltorito_sectionheader_entry section_header;
395898
 
395898
 	memset(boot_desc, 0, sizeof (*boot_desc));
395898
 	boot_desc->type[0] = 0;
395898
@@ -317,7 +318,7 @@ get_torito_desc(struct eltorito_boot_descriptor *boot_desc)
395898
 	 */
395898
 	memset(&valid_desc, 0, sizeof (valid_desc));
395898
 	valid_desc.headerid[0] = 1;
395898
-	valid_desc.arch[0] = EL_TORITO_ARCH_x86;
395898
+	valid_desc.arch[0] = first_boot_entry->arch;
395898
 
395898
 	/*
395898
 	 * we'll shove start of publisher id into id field,
395898
@@ -347,10 +348,53 @@ get_torito_desc(struct eltorito_boot_descriptor *boot_desc)
395898
 	/* now write it to the virtual boot catalog */
395898
 	memcpy(de2->table, &valid_desc, 32);
395898
 
395898
-	for (current_boot_entry = first_boot_entry, offset = sizeof (valid_desc);
395898
-		current_boot_entry != NULL;
395898
-		current_boot_entry = current_boot_entry->next,
395898
-		offset += sizeof (boot_desc_record)) {
395898
+	/* Fill the first entry, since it's special and already has the
395898
+	 * matching header via the validation header... */
395898
+	offset = sizeof (valid_desc);
395898
+	current_boot_entry = first_boot_entry;
395898
+
395898
+	if (offset >= SECTOR_SIZE) {
395898
+#ifdef	USE_LIBSCHILY
395898
+		comerrno(EX_BAD, "Too many El Torito boot entries\n");
395898
+#else
395898
+		fprintf(stderr,	"Too many El Torito boot entries\n");
395898
+		exit(1);
395898
+#endif
395898
+	}
395898
+	fill_boot_desc(&boot_desc_record, current_boot_entry);
395898
+	memcpy(de2->table + offset, &boot_desc_record,
395898
+				sizeof (boot_desc_record));
395898
+
395898
+	offset += sizeof(boot_desc_record);
395898
+
395898
+	for (current_boot_entry = current_boot_entry->next;
395898
+			current_boot_entry != NULL;
395898
+			current_boot_entry = current_boot_entry->next) {
395898
+		struct eltorito_sectionheader_entry section_header;
395898
+
395898
+		if (offset >= SECTOR_SIZE) {
395898
+#ifdef	USE_LIBSCHILY
395898
+			comerrno(EX_BAD,
395898
+			"Too many El Torito boot entries\n");
395898
+#else
395898
+			fprintf(stderr,
395898
+			"Too many El Torito boot entries\n");
395898
+			exit(1);
395898
+#endif
395898
+		}
395898
+
395898
+		memset(&section_header, '\0', sizeof(section_header));
395898
+		if (current_boot_entry->next)
395898
+			section_header.headerid[0] = EL_TORITO_SECTION_HEADER;
395898
+		else
395898
+			section_header.headerid[0] = EL_TORITO_LAST_SECTION_HEADER;
395898
+
395898
+		section_header.arch[0] = current_boot_entry->arch;
395898
+		set_721(section_header.num_entries, 1);
395898
+
395898
+		memcpy(de2->table + offset, &section_header,
395898
+					sizeof(section_header));
395898
+		offset += sizeof(section_header);
395898
 
395898
 		if (offset >= SECTOR_SIZE) {
395898
 #ifdef	USE_LIBSCHILY
395898
@@ -365,6 +409,8 @@ get_torito_desc(struct eltorito_boot_descriptor *boot_desc)
395898
 		fill_boot_desc(&boot_desc_record, current_boot_entry);
395898
 		memcpy(de2->table + offset, &boot_desc_record,
395898
 					sizeof (boot_desc_record));
395898
+		offset += sizeof (boot_desc_record);
395898
+
395898
 	}
395898
 }/* get_torito_desc(... */
395898
 
395898
diff --git a/genisoimage/genisoimage.c b/genisoimage/genisoimage.c
395898
index a5b0b46..8add1ac 100644
395898
--- a/genisoimage/genisoimage.c
395898
+++ b/genisoimage/genisoimage.c
395898
@@ -47,6 +47,7 @@
395898
 
395898
 #include <mconfig.h>
395898
 #include "genisoimage.h"
395898
+#include "iso9660.h"
395898
 #include <errno.h>
395898
 #include <timedefs.h>
395898
 #include <fctldefs.h>
395898
@@ -523,6 +524,8 @@ static const struct ld_option ld_options[] =
395898
 	'\0', NULL, "Set debug flag", ONE_DASH},
395898
 	{{"eltorito-boot", required_argument, NULL, 'b'},
395898
 	'b', "FILE", "Set El Torito boot image name", ONE_DASH},
395898
+	{{"efi-boot", required_argument, NULL, 'e'},
395898
+	'e', "FILE", "Set EFI boot image name", ONE_DASH},
395898
 	{{"eltorito-alt-boot", no_argument, NULL, OPTION_ALT_BOOT},
395898
 	'\0', NULL, "Start specifying alternative El Torito boot parameters", ONE_DASH},
395898
 	{{"sparc-boot", required_argument, NULL, 'B'},
395898
@@ -1502,6 +1505,7 @@ int main(int argc, char *argv[])
395898
 			all_files = 0;
395898
 			break;
395898
 		case 'b':
395898
+		case 'e':
395898
 			do_sort++;		/* We sort bootcat/botimage */
395898
 			use_eltorito++;
395898
 			boot_image = optarg;	/* pathname of the boot image */
395898
@@ -1517,6 +1521,10 @@ int main(int argc, char *argv[])
395898
 #endif
395898
 			}
395898
 			get_boot_entry();
395898
+			if (c == 'e')
395898
+				current_boot_entry->arch = EL_TORITO_ARCH_EFI;
395898
+			else
395898
+				current_boot_entry->arch = EL_TORITO_ARCH_x86;
395898
 			current_boot_entry->boot_image = boot_image;
395898
 			break;
395898
 		case OPTION_ALT_BOOT:
395898
diff --git a/genisoimage/genisoimage.h b/genisoimage/genisoimage.h
395898
index bbedfb0..76e5e21 100644
395898
--- a/genisoimage/genisoimage.h
395898
+++ b/genisoimage/genisoimage.h
395898
@@ -293,6 +293,7 @@ struct deferred_write {
395898
 struct eltorito_boot_entry_info {
395898
 	struct eltorito_boot_entry_info *next;
395898
 	char		*boot_image;
395898
+	char		arch;
395898
 	int		not_bootable;
395898
 	int		no_emul_boot;
395898
 	int		hard_disk_boot;
395898
diff --git a/genisoimage/iso9660.h b/genisoimage/iso9660.h
395898
index c74c2a9..c8b7a05 100644
395898
--- a/genisoimage/iso9660.h
395898
+++ b/genisoimage/iso9660.h
395898
@@ -62,10 +62,14 @@ struct iso_volume_descriptor {
395898
 #define	EL_TORITO_ARCH_x86	0
395898
 #define	EL_TORITO_ARCH_PPC	1
395898
 #define	EL_TORITO_ARCH_MAC	2
395898
+#define	EL_TORITO_ARCH_EFI	0xef
395898
 
395898
 #define	EL_TORITO_BOOTABLE	0x88
395898
 #define	EL_TORITO_NOT_BOOTABLE	0
395898
 
395898
+#define	EL_TORITO_SECTION_HEADER	0x90
395898
+#define	EL_TORITO_LAST_SECTION_HEADER	0x91
395898
+
395898
 #define	EL_TORITO_MEDIA_NOEMUL	0
395898
 #define	EL_TORITO_MEDIA_12FLOP	1
395898
 #define	EL_TORITO_MEDIA_144FLOP	2
395898
@@ -173,7 +177,7 @@ struct eltorito_validation_entry {
395898
 struct eltorito_defaultboot_entry {
395898
 	char boot_id			[ISODCL(1,    1)]; /* 711 */
395898
 	char boot_media			[ISODCL(2,    2)];
395898
-	char loadseg			[ISODCL(3,    4)]; /* 711 */
395898
+	char loadseg			[ISODCL(3,    4)]; /* 712 */
395898
 	char sys_type			[ISODCL(5,    5)];
395898
 	char pad1			[ISODCL(6,    6)];
395898
 	char nsect			[ISODCL(7,    8)];
395898
@@ -181,6 +185,14 @@ struct eltorito_defaultboot_entry {
395898
 	char pad2			[ISODCL(13,  32)];
395898
 };
395898
 
395898
+/* El Torito Section Header Entry in boot catalog */
395898
+struct eltorito_sectionheader_entry {
395898
+	char headerid			[ISODCL(1,    1)]; /* 711 */
395898
+	char arch			[ISODCL(2,    2)];
395898
+	char num_entries		[ISODCL(3,    4)]; /* 711 */
395898
+	char id				[ISODCL(5,   32)];
395898
+};
395898
+
395898
 /*
395898
  * XXX JS: The next two structures have odd lengths!
395898
  * Some compilers (e.g. on Sun3/mc68020) padd the structures to even length.