Complete Yocto mirror with license table for TQMa6UL (2038-compliance)

- 264 license table entries with exact download URLs (224/264 resolved)
- Complete sources/ directory with all BitBake recipes
- Build configuration: tqma6ul-multi-mba6ulx, spaetzle (musl)
- Full traceability for Softwarefreigabeantrag
- GCC 13.4.0, Linux 6.6.102, U-Boot 2023.04, musl 1.2.4
- License distribution: GPL-2.0 (24), MIT (23), GPL-2.0+ (18), BSD-3 (16)
This commit is contained in:
Siggi (OpenClaw Agent)
2026-03-01 20:58:18 +00:00
commit 16accb6b24
15086 changed files with 1292356 additions and 0 deletions

View File

@@ -0,0 +1,81 @@
From a469ce05055c44fdca1ca094ff3a735cc059480d Mon Sep 17 00:00:00 2001
From: Robert Yang <liezhi.yang@windriver.com>
Date: Wed, 31 Dec 2014 16:01:55 +0800
Subject: [PATCH] linux/syslinux: support ext2/3/4 device
* Support ext2/3/4 deivce.
* The open_ext2_fs() checks whether it is an ext2/3/4 device,
do the ext2/3/4 installation (install_to_ext2()) if yes, otherwise go
on to the fat/ntfs.
* The ext2/3/4 support doesn't require root privileges since it doesn't need
mount (but write permission is required).
Upstream-Status: Submitted [https://www.syslinux.org/archives/2015-January/023039.html]
Signed-off-by: Robert Yang <liezhi.yang@windriver.com>
Tested-by: Du Dolpher <dolpher.du@intel.com>
---
linux/syslinux.c | 36 ++++++++++++++++++++++++++++++++++++
1 file changed, 36 insertions(+)
diff --git a/linux/syslinux.c b/linux/syslinux.c
index 46d5624..1cc276b 100755
--- a/linux/syslinux.c
+++ b/linux/syslinux.c
@@ -257,6 +257,23 @@ int do_open_file(char *name)
return fd;
}
+/*
+ * Check whether the device contains an ext2, ext3 or ext4 fs and open it if
+ * true.
+ * return value:
+ * 0: Everything is OK
+ * 1: Not an ext2, ext3 or ext4
+ * -1: unexpected error
+ */
+static int open_ext2_fs(const char *device, const char *subdir)
+{
+}
+
+/* The install func for ext2, ext3 and ext4 */
+static int install_to_ext2(const char *device, int dev_fd, const char *subdir)
+{
+}
+
int main(int argc, char *argv[])
{
static unsigned char sectbuf[SECTOR_SIZE];
@@ -314,6 +331,24 @@ int main(int argc, char *argv[])
die("can't combine an offset with a block device");
}
+ /*
+ * Check if it is an ext2, ext3 or ext4
+ */
+ rv = open_ext2_fs(opt.device, subdir);
+ if (rv == 0) {
+ if (install_to_ext2(opt.device, dev_fd, subdir)) {
+ fprintf(stderr, "%s: installation failed\n", opt.device);
+ exit(1);
+ }
+ return 0;
+ /* Unexpected errors */
+ } else if (rv == -1) {
+ exit(1);
+ }
+
+ /* Reset rv */
+ rv = 0;
+
xpread(dev_fd, sectbuf, SECTOR_SIZE, opt.offset);
fsync(dev_fd);
@@ -323,6 +358,7 @@ int main(int argc, char *argv[])
*/
if ((errmsg = syslinux_check_bootsect(sectbuf, &fs_type))) {
fprintf(stderr, "%s: %s\n", opt.device, errmsg);
+ fprintf(stderr, "%s: supported fs: fat/ntfs/ext2/ex3/ext4\n", program);
exit(1);
}

View File

@@ -0,0 +1,138 @@
From c6ddb179577dd4c4ea4d1d154f979e90e53d6bf1 Mon Sep 17 00:00:00 2001
From: Robert Yang <liezhi.yang@windriver.com>
Date: Wed, 31 Dec 2014 16:09:18 +0800
Subject: [PATCH] linux/syslinux: implement open_ext2_fs()
The open_ext2_fs() checks whether it is an ext2/ext3/ext4 device, and
return:
0: It is an ext2, ext3 or ext4.
1: Not an ext2, ext3 or ext4.
-1: unexpected error.
Upstream-Status: Submitted
Signed-off-by: Robert Yang <liezhi.yang@windriver.com>
Tested-by: Du Dolpher <dolpher.du@intel.com>
---
linux/Makefile | 2 +-
linux/syslinux.c | 80 ++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 81 insertions(+), 1 deletion(-)
diff --git a/linux/Makefile b/linux/Makefile
index 5a49d81..67cbbb4 100644
--- a/linux/Makefile
+++ b/linux/Makefile
@@ -52,7 +52,7 @@ spotless: clean
installer: syslinux syslinux-nomtools
syslinux: $(OBJS)
- $(CC) $(LDFLAGS) -o $@ $^
+ $(CC) $(LDFLAGS) -o $@ $^ -lext2fs
syslinux-nomtools: syslinux
ln -f $< $@
diff --git a/linux/syslinux.c b/linux/syslinux.c
index 1cc276b..f3727ea 100755
--- a/linux/syslinux.c
+++ b/linux/syslinux.c
@@ -73,6 +73,7 @@
#include "syslxfs.h"
#include "setadv.h"
#include "syslxopt.h" /* unified options */
+#include <ext2fs/ext2fs.h>
extern const char *program; /* Name of program */
@@ -83,6 +84,9 @@ char *mntpath = NULL; /* Path on which to mount */
int loop_fd = -1; /* Loop device */
#endif
+ext2_filsys e2fs = NULL; /* Ext2/3/4 filesystem */
+ext2_ino_t root, cwd; /* The root and cwd of e2fs */
+
void __attribute__ ((noreturn)) die(const char *msg)
{
fprintf(stderr, "%s: %s\n", program, msg);
@@ -267,6 +271,82 @@ int do_open_file(char *name)
*/
static int open_ext2_fs(const char *device, const char *subdir)
{
+ int retval;
+ int open_flag = EXT2_FLAG_RW, mount_flags;
+ ext2_ino_t dirino;
+ char opt_string[40];
+
+ if (opt.offset) {
+ sprintf(opt_string, "offset=%llu", (unsigned long long)opt.offset);
+ retval = ext2fs_open2(device, opt_string, open_flag, 0, 0, unix_io_manager, &e2fs);
+ } else
+ retval = ext2fs_open(device, open_flag, 0, 0, unix_io_manager, &e2fs);
+ if (retval) {
+ /* It might not be an extN fs, so we need check magic firstly */
+ if (retval == EXT2_ET_BAD_MAGIC) {
+ /* Do nothing, return silently */
+ return 1;
+ } else {
+ fprintf(stderr, "%s: error while trying to open: %s\n",
+ program, device);
+ return -1;
+ }
+ }
+
+ /* Stop if it is mounted */
+ retval = ext2fs_check_if_mounted(device, &mount_flags);
+ if (retval) {
+ fprintf(stderr, "%s: ext2fs_check_if_mount() error on %s\n",
+ program, device);
+ goto fail;
+ }
+
+ if (mount_flags & EXT2_MF_MOUNTED) {
+ fprintf(stderr, "%s: %s is mounted\n", program, device);
+ goto fail;
+ }
+
+ e2fs->default_bitmap_type = EXT2FS_BMAP64_RBTREE;
+
+ /* Read the inode map */
+ retval = ext2fs_read_inode_bitmap(e2fs);
+ if (retval) {
+ fprintf(stderr, "%s: while reading inode bitmap: %s\n",
+ program, device);
+ goto fail;
+ }
+
+ /* Read the block map */
+ retval = ext2fs_read_block_bitmap(e2fs);
+ if (retval) {
+ fprintf(stderr, "%s: while reading block bitmap: %s\n",
+ program, device);
+ goto fail;
+ }
+
+ root = cwd = EXT2_ROOT_INO;
+ /* Check the subdir */
+ if (strcmp(subdir, "/")) {
+ retval = ext2fs_namei(e2fs, root, cwd, subdir, &dirino);
+ if (retval) {
+ fprintf(stderr, "%s: failed to find dir %s on %s\n",
+ program, subdir, device);
+ goto fail;
+ }
+
+ retval = ext2fs_check_directory(e2fs, dirino);
+ if (retval) {
+ fprintf(stderr, "%s: failed to cd to: %s\n", program, subdir);
+ goto fail;
+ }
+ cwd = dirino;
+ }
+
+ return 0;
+
+fail:
+ (void) ext2fs_close(e2fs);
+ return -1;
}
/* The install func for ext2, ext3 and ext4 */

View File

@@ -0,0 +1,113 @@
From 9110cf47d04ca1958d14228908a5c57a23769e7d Mon Sep 17 00:00:00 2001
From: Robert Yang <liezhi.yang@windriver.com>
Date: Wed, 31 Dec 2014 16:17:42 +0800
Subject: [PATCH] linux/syslinux: implement install_to_ext2()
* The handle_adv_on_ext() checks whether we only need update adv.
* The write_to_ext() installs files (ldlinux.sys or ldlinux.c32) to the
device.
* The install_bootblock() installs the boot block.
Upstream-Status: Submitted
Signed-off-by: Robert Yang <liezhi.yang@windriver.com>
Tested-by: Du Dolpher <dolpher.du@intel.com>
---
linux/syslinux.c | 79 ++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 79 insertions(+)
diff --git a/linux/syslinux.c b/linux/syslinux.c
index f3727ea..fc5edb1 100755
--- a/linux/syslinux.c
+++ b/linux/syslinux.c
@@ -347,11 +347,90 @@ static int open_ext2_fs(const char *device, const char *subdir)
fail:
(void) ext2fs_close(e2fs);
return -1;
+
+}
+
+/*
+ * Install the boot block on the specified device.
+ * Must be run AFTER file installed.
+ */
+int install_bootblock(int fd, const char *device)
+{
+}
+
+static int handle_adv_on_ext(void)
+{
+}
+
+/* Write files, adv, boot sector */
+static int write_to_ext(const char *filename, const char *str, int length,
+ int i_flags, int dev_fd, const char *subdir)
+{
}
/* The install func for ext2, ext3 and ext4 */
static int install_to_ext2(const char *device, int dev_fd, const char *subdir)
{
+ int retval;
+ ext2_ino_t oldino;
+
+ const char *file = "ldlinux.sys";
+ const char *oldfile = "extlinux.sys";
+ const char *c32file = "ldlinux.c32";
+
+ /* Handle the adv */
+ if (handle_adv_on_ext() < 0) {
+ fprintf(stderr, "%s: error while handling ADV on %s\n",
+ program, device);
+ retval = 1;
+ goto fail;
+ }
+
+ /* Return if only need update the adv */
+ if (opt.update_only == -1) {
+ return ext2fs_close(e2fs);
+ }
+
+ /* Write ldlinux.sys, adv, boot sector */
+ retval = write_to_ext(file, (const char _force *)boot_image,
+ boot_image_len, EXT2_IMMUTABLE_FL, dev_fd, subdir);
+ if (retval) {
+ fprintf(stderr, "%s: ERROR: while writing: %s.\n",
+ program, file);
+ goto fail;
+ }
+
+ /* Write ldlinux.c32 */
+ retval = write_to_ext(c32file,
+ (const char _force *)syslinux_ldlinuxc32,
+ syslinux_ldlinuxc32_len, 0, dev_fd, subdir);
+ if (retval) {
+ fprintf(stderr, "%s: ERROR: while writing: %s.\n",
+ program, c32file);
+ goto fail;
+ }
+
+ /* Look if we have the extlinux.sys and remove it*/
+ retval = ext2fs_namei(e2fs, root, cwd, oldfile, &oldino);
+ if (retval == 0) {
+ retval = ext2fs_unlink(e2fs, cwd, oldfile, oldino, 0);
+ if (retval) {
+ fprintf(stderr, "%s: ERROR: failed to unlink: %s\n",
+ program, oldfile);
+ goto fail;
+ }
+ } else {
+ retval = 0;
+ }
+
+ sync();
+ retval = install_bootblock(dev_fd, device);
+ close(dev_fd);
+ sync();
+
+fail:
+ (void) ext2fs_close(e2fs);
+ return retval;
}
int main(int argc, char *argv[])

View File

@@ -0,0 +1,88 @@
From 1957fc6c069493c6789557936adb675f5e7e51ba Mon Sep 17 00:00:00 2001
From: Robert Yang <liezhi.yang@windriver.com>
Date: Wed, 31 Dec 2014 16:43:37 +0800
Subject: [PATCH] linux/syslinux: add ext_file_read() and ext_file_write()
Will use them to read and write on the extX device.
Upstream-Status: Submitted
Signed-off-by: Robert Yang <liezhi.yang@windriver.com>
Tested-by: Du Dolpher <dolpher.du@intel.com>
---
linux/syslinux.c | 62 ++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 62 insertions(+)
diff --git a/linux/syslinux.c b/linux/syslinux.c
index fc5edb1..c7c1994 100755
--- a/linux/syslinux.c
+++ b/linux/syslinux.c
@@ -350,6 +350,68 @@ fail:
}
+/* Read from an ext2_file */
+static int ext_file_read(ext2_file_t e2_file, void *buf, size_t count,
+ off_t offset, const char *msg)
+{
+ int retval;
+ char *ptr = (char *) buf;
+ unsigned int got = 0;
+ size_t done = 0;
+
+ /* Always lseek since e2_file is uncontrolled by this func */
+ if (ext2fs_file_lseek(e2_file, offset, EXT2_SEEK_SET, NULL)) {
+ fprintf(stderr, "%s: ext2fs_file_lseek() failed.\n",
+ program);
+ return -1;
+ }
+
+ while (1) {
+ retval = ext2fs_file_read(e2_file, ptr, count, &got);
+ if (retval) {
+ fprintf(stderr, "%s: error while reading %s\n",
+ program, msg);
+ return -1;
+ }
+ count -= got;
+ ptr += got;
+ done += got;
+ if (got == 0 || count == 0)
+ break;
+ }
+
+ return done;
+}
+
+/* Write to an ext2_file */
+static int ext_file_write(ext2_file_t e2_file, const void *buf, size_t count,
+ off_t offset)
+{
+ const char *ptr = (const char *) buf;
+ unsigned int written = 0;
+ size_t done = 0;
+
+ /* Always lseek since e2_file is uncontrolled by this func */
+ if (ext2fs_file_lseek(e2_file, offset, EXT2_SEEK_SET, NULL)) {
+ fprintf(stderr, "%s: ext2fs_file_lseek() failed.\n",
+ program);
+ return -1;
+ }
+
+ while (count > 0) {
+ if (ext2fs_file_write(e2_file, ptr, count, &written)) {
+ fprintf(stderr, "%s: failed to write syslinux adv.\n",
+ program);
+ return -1;
+ }
+ count -= written;
+ ptr += written;
+ done += written;
+ }
+
+ return done;
+}
+
/*
* Install the boot block on the specified device.
* Must be run AFTER file installed.

View File

@@ -0,0 +1,124 @@
From ee3a60829edc9d3344dc872fb0158e7b006f02be Mon Sep 17 00:00:00 2001
From: Robert Yang <liezhi.yang@windriver.com>
Date: Wed, 31 Dec 2014 16:47:52 +0800
Subject: [PATCH] linux/syslinux: implement handle_adv_on_ext()
It reads adv if found on the device, or resets syslinux_adv, or update
the adv if update adv only.
Upstream-Status: Submitted
Signed-off-by: Robert Yang <liezhi.yang@windriver.com>
Tested-by: Du Dolpher <dolpher.du@intel.com>
---
linux/syslinux.c | 97 ++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 97 insertions(+)
diff --git a/linux/syslinux.c b/linux/syslinux.c
index c7c1994..90b8edd 100755
--- a/linux/syslinux.c
+++ b/linux/syslinux.c
@@ -422,6 +422,103 @@ int install_bootblock(int fd, const char *device)
static int handle_adv_on_ext(void)
{
+ int i, retval, found_file;
+ int need_close = 2; /* 2 means no need extra close */
+ char *filenames[2] = {"ldlinux.sys", "extlinux.sys"};
+ char *filename;
+ ext2_ino_t newino;
+ ext2_file_t e2_file;
+ struct ext2_inode inode;
+
+ for (i = 0; i < 2; i++) {
+ filename = filenames[i];
+ found_file = 0;
+ retval = ext2fs_namei(e2fs, root, cwd, filename, &newino);
+ if (retval == 0) {
+ found_file = 1;
+ } else
+ continue;
+
+ need_close = i;
+
+ retval = ext2fs_file_open(e2fs, newino, EXT2_FLAG_RW, &e2_file);
+ if (retval) {
+ fprintf(stderr, "%s: failed to open %s\n",
+ program, filename);
+ goto fail;
+ }
+
+ retval = ext2fs_read_inode(e2fs, newino, &inode);
+ if (retval) {
+ fprintf(stderr, "%s: error while reading inode: %u, file: %s\n",
+ program, newino, filename);
+ goto fail;
+ }
+
+ /* Check the size to see if too small to read */
+ if (inode.i_size < 2 * ADV_SIZE) {
+ if (opt.update_only == -1) {
+ fprintf(stderr, "%s: failed to write auxilliary data\n\
+ the size of %s is too small (need --update)?\n",
+ program, filename);
+ retval = -1;
+ goto fail;
+ }
+ syslinux_reset_adv(syslinux_adv);
+ found_file = 0;
+ break;
+ }
+
+ /* Read the adv */
+ retval = ext_file_read(e2_file, syslinux_adv, 2 * ADV_SIZE,
+ inode.i_size - 2 * ADV_SIZE, "ADV");
+ if (retval == -1)
+ goto fail;
+ if (retval == 2 * ADV_SIZE) {
+ retval = syslinux_validate_adv(syslinux_adv);
+ /* Read the adv successfully */
+ if (retval == 0)
+ break;
+ }
+
+ /* Close the file if reaches here, otherwise we leave the file
+ * open in case we need write it */
+ need_close = 2;
+ retval = ext2fs_file_close(e2_file);
+ if (retval) {
+ fprintf(stderr, "%s: error while closing %s\n",
+ program, filename);
+ return retval;
+ }
+ }
+
+ if (!found_file) {
+ if (opt.update_only == -1) {
+ fprintf(stderr, "%s: no ldlinux.sys or extlinux.sys found on the device\n",
+ program);
+ return -1;
+ }
+ syslinux_reset_adv(syslinux_adv);
+ }
+
+ /* The modify_adv will reset the adv if opt.reset_adv */
+ if (modify_adv() < 0) {
+ fprintf(stderr, "%s: error while modifying adv\n", program);
+ retval = -1;
+ goto fail;
+ }
+
+ /* Write adv if update_only == -1 and found file */
+ if (opt.update_only == -1 && found_file) {
+ if (ext_file_write(e2_file, syslinux_adv, 2 * ADV_SIZE ,
+ inode.i_size - 2 * ADV_SIZE) == -1)
+ goto fail;
+ }
+
+fail:
+ if (need_close != 2)
+ (void) ext2fs_file_close(e2_file);
+ return retval;
}
/* Write files, adv, boot sector */

View File

@@ -0,0 +1,212 @@
From 758731ce2432ab29a73505bbeb99a960996ab686 Mon Sep 17 00:00:00 2001
From: Robert Yang <liezhi.yang@windriver.com>
Date: Wed, 31 Dec 2014 17:20:43 +0800
Subject: [PATCH] linux/syslinux: implement write_to_ext() and add
syslinuxext.c
* The write_to_ext() write file to the extX device, and handle the boot
sector.
* The syslinuxext.c is used for placing the code which are used by
extlinux and syslinux (which is syslinux_patch_bootsect()).
Upstream-Status: Submitted
Signed-off-by: Robert Yang <liezhi.yang@windriver.com>
Tested-by: Du Dolpher <dolpher.du@intel.com>
---
libinstaller/syslinuxext.c | 7 +++
libinstaller/syslinuxext.h | 5 ++
linux/Makefile | 3 +-
linux/syslinux.c | 118 +++++++++++++++++++++++++++++++++++++
4 files changed, 132 insertions(+), 1 deletion(-)
create mode 100644 libinstaller/syslinuxext.c
create mode 100644 libinstaller/syslinuxext.h
diff --git a/libinstaller/syslinuxext.c b/libinstaller/syslinuxext.c
new file mode 100644
index 0000000..bb54cef
--- /dev/null
+++ b/libinstaller/syslinuxext.c
@@ -0,0 +1,7 @@
+#define _GNU_SOURCE
+
+/* Patch syslinux_bootsect */
+void syslinux_patch_bootsect(int dev_fd)
+{
+}
+
diff --git a/libinstaller/syslinuxext.h b/libinstaller/syslinuxext.h
new file mode 100644
index 0000000..8abd8b9
--- /dev/null
+++ b/libinstaller/syslinuxext.h
@@ -0,0 +1,5 @@
+#ifndef EXT2_SUPER_OFFSET
+#define EXT2_SUPER_OFFSET 1024
+#endif
+
+void syslinux_patch_bootsect(int dev_fd);
diff --git a/linux/Makefile b/linux/Makefile
index 67cbbb4..567134c 100644
--- a/linux/Makefile
+++ b/linux/Makefile
@@ -31,7 +31,8 @@ SRCS = syslinux.c \
../libinstaller/syslxmod.c \
../libinstaller/bootsect_bin.c \
../libinstaller/ldlinuxc32_bin.c \
- ../libinstaller/ldlinux_bin.c
+ ../libinstaller/ldlinux_bin.c \
+ ../libinstaller/syslinuxext.c
OBJS = $(patsubst %.c,%.o,$(notdir $(SRCS)))
.SUFFIXES: .c .o .i .s .S
diff --git a/linux/syslinux.c b/linux/syslinux.c
index 90b8edd..7a20fe6 100755
--- a/linux/syslinux.c
+++ b/linux/syslinux.c
@@ -46,6 +46,7 @@
#include <sys/types.h>
#include <sys/wait.h>
#include <sys/mount.h>
+#include <time.h>
#include "linuxioctl.h"
@@ -73,6 +74,7 @@
#include "syslxfs.h"
#include "setadv.h"
#include "syslxopt.h" /* unified options */
+#include "syslinuxext.h"
#include <ext2fs/ext2fs.h>
extern const char *program; /* Name of program */
@@ -420,6 +422,12 @@ int install_bootblock(int fd, const char *device)
{
}
+/* Construct the boot file map */
+int ext_construct_sectmap_fs(ext2_filsys fs, ext2_ino_t newino,
+ sector_t *sectors, int nsect)
+{
+}
+
static int handle_adv_on_ext(void)
{
int i, retval, found_file;
@@ -525,6 +533,116 @@ fail:
static int write_to_ext(const char *filename, const char *str, int length,
int i_flags, int dev_fd, const char *subdir)
{
+ ext2_ino_t newino;
+ struct ext2_inode inode;
+ int retval, i, modbytes, nsect;
+ ext2_file_t e2_file;
+ sector_t *sectors;
+
+ /* Remove it if it is already exists */
+ retval = ext2fs_namei(e2fs, root, cwd, filename, &newino);
+ if (retval == 0) {
+ retval = ext2fs_unlink(e2fs, cwd, filename, newino, 0);
+ if (retval) {
+ fprintf(stderr, "%s: failed to unlink: %s\n", program, filename);
+ return retval;
+ }
+ }
+
+ /* Create new inode */
+ retval = ext2fs_new_inode(e2fs, cwd, 010755, 0, &newino);
+ if (retval) {
+ fprintf(stderr, "%s: ERROR: failed to create inode for: %s\n",
+ program, filename);
+ return retval;
+ }
+
+ /* Link the inode and the filename */
+ retval = ext2fs_link(e2fs, cwd, filename, newino, EXT2_FT_REG_FILE);
+ if (retval) {
+ fprintf(stderr, "%s: ERROR: failed to link inode for: %s.\n",
+ program, filename);
+ return retval;
+ }
+
+ if (ext2fs_test_inode_bitmap2(e2fs->inode_map, newino))
+ fprintf(stderr, "%s: warning: inode already set %s.\n",
+ program, filename);
+
+ ext2fs_inode_alloc_stats2(e2fs, newino, +1, 0);
+ memset(&inode, 0, sizeof(inode));
+ inode.i_mode = LINUX_S_IFREG | LINUX_S_IRUSR | LINUX_S_IRGRP
+ | LINUX_S_IROTH;
+ inode.i_flags |= i_flags;
+ inode.i_atime = inode.i_ctime = inode.i_mtime =
+ e2fs->now ? e2fs->now : time(0);
+ inode.i_links_count = 1;
+ if (e2fs->super->s_feature_incompat &
+ EXT3_FEATURE_INCOMPAT_EXTENTS) {
+ struct ext3_extent_header *eh;
+
+ eh = (struct ext3_extent_header *) &inode.i_block[0];
+ eh->eh_depth = 0;
+ eh->eh_entries = 0;
+ eh->eh_magic = ext2fs_cpu_to_le16(EXT3_EXT_MAGIC);
+ i = (sizeof(inode.i_block) - sizeof(*eh)) /
+ sizeof(struct ext3_extent);
+ eh->eh_max = ext2fs_cpu_to_le16(i);
+ inode.i_flags |= EXT4_EXTENTS_FL;
+ }
+
+ retval = ext2fs_write_new_inode(e2fs, newino, &inode);
+ if (retval) {
+ fprintf(stderr, "%s: ERROR: while writting inode %d.\n",
+ program, newino);
+ return 1;
+ }
+
+ retval = ext2fs_file_open(e2fs, newino, EXT2_FILE_WRITE, &e2_file);
+ if (retval) {
+ fprintf(stderr, "%s: ERROR: failed to open %s.\n",
+ program, filename);
+ return 1;
+ }
+
+ /* Write to file */
+ if (ext_file_write(e2_file, str, length, 0) == -1)
+ goto fail;
+
+ if (strcmp(filename, "ldlinux.sys") == 0) {
+ /* Write ADV */
+ if (ext_file_write(e2_file, syslinux_adv, 2 * ADV_SIZE,
+ boot_image_len) == -1)
+ goto fail;
+
+ /* Patch syslinux_bootsect */
+ syslinux_patch_bootsect(dev_fd);
+
+ /* Patch ldlinux.sys */
+ nsect = (boot_image_len + SECTOR_SIZE - 1) >> SECTOR_SHIFT;
+ nsect += 2; /* Two sectors for the ADV */
+ sectors = alloca(sizeof(sector_t) * nsect);
+ memset(sectors, 0, nsect * sizeof *sectors);
+ /* The sectors will be modified and used by syslinux_patch() */
+ retval = ext_construct_sectmap_fs(e2fs, newino, sectors, nsect);
+ if (retval)
+ goto fail;
+
+ /* Create the modified image in memory */
+ modbytes = syslinux_patch(sectors, nsect, opt.stupid_mode,
+ opt.raid_mode, subdir, NULL);
+
+ /* Rewrite the first modbytes of ldlinux.sys */
+ if (ext_file_write(e2_file, str, modbytes, 0) == -1) {
+ fprintf(stderr, "%s: ERROR: failed to patch %s.\n", program,
+ filename);
+ goto fail;
+ }
+ }
+
+fail:
+ (void) ext2fs_file_close(e2_file);
+ return retval;
}
/* The install func for ext2, ext3 and ext4 */

View File

@@ -0,0 +1,81 @@
From 906205015601d5d1190e7326f51ea4316a74a479 Mon Sep 17 00:00:00 2001
From: Robert Yang <liezhi.yang@windriver.com>
Date: Fri, 2 Jan 2015 12:18:02 +0800
Subject: [PATCH] linux/syslinux: implement ext_construct_sectmap_fs()
The ext_construct_sectmap_fs() constucts the sector according to the
bmap.
Upstream-Status: Submitted
Signed-off-by: Robert Yang <liezhi.yang@windriver.com>
Tested-by: Du Dolpher <dolpher.du@intel.com>
---
linux/syslinux.c | 50 ++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 50 insertions(+)
diff --git a/linux/syslinux.c b/linux/syslinux.c
index 7a20fe6..4e43921 100755
--- a/linux/syslinux.c
+++ b/linux/syslinux.c
@@ -422,10 +422,60 @@ int install_bootblock(int fd, const char *device)
{
}
+/* The file's block count */
+int block_count = 0;
+static int get_block_count(ext2_filsys fs EXT2FS_ATTR((unused)),
+ blk64_t *blocknr EXT2FS_ATTR((unused)),
+ e2_blkcnt_t blockcnt EXT2FS_ATTR((unused)),
+ blk64_t ref_block EXT2FS_ATTR((unused)),
+ int ref_offset EXT2FS_ATTR((unused)),
+ void *private EXT2FS_ATTR((unused)))
+{
+ block_count++;
+ return 0;
+}
+
/* Construct the boot file map */
int ext_construct_sectmap_fs(ext2_filsys fs, ext2_ino_t newino,
sector_t *sectors, int nsect)
{
+ blk64_t pblk, blksize, blk = 0;
+ sector_t sec;
+ unsigned int i;
+ int retval;
+
+ blksize = fs->blocksize;
+ blksize >>= SECTOR_SHIFT;
+
+ /* Get the total blocks no. */
+ retval = ext2fs_block_iterate3(fs, newino, BLOCK_FLAG_READ_ONLY,
+ NULL, get_block_count, NULL);
+ if (retval) {
+ fprintf(stderr, "%s: ERROR: ext2fs_block_iterate3() failed.\n", program);
+ return -1;
+ }
+
+ while (nsect) {
+ if (block_count-- == 0)
+ break;
+
+ /* Get the physical block no. (bmap) */
+ retval = ext2fs_bmap2(fs, newino, 0, 0, 0, blk, 0, &pblk);
+ if (retval) {
+ fprintf(stderr, "%s: ERROR: ext2fs_bmap2() failed.\n", program);
+ return -1;
+ }
+
+ blk++;
+ sec = (sector_t)pblk * blksize;
+ for (i = 0; i < blksize; i++) {
+ *sectors++ = sec++;
+ if (! --nsect)
+ break;
+ }
+ }
+
+ return 0;
}
static int handle_adv_on_ext(void)

View File

@@ -0,0 +1,428 @@
From acfc8214d3d60b7e251ae66a59b81cdd1ff7a6dc Mon Sep 17 00:00:00 2001
From: Robert Yang <liezhi.yang@windriver.com>
Date: Fri, 2 Jan 2015 12:26:46 +0800
Subject: [PATCH] libinstaller/syslinuxext: implement syslinux_patch_bootsect()
Move the related from extlinux/main.c to libinstaller/syslinuxext.c, the
syslinux_patch_bootsect() are used by both extlinux/main.c and
linux/syslinux.c.
Upstream-Status: Submitted
Signed-off-by: Robert Yang <liezhi.yang@windriver.com>
Tested-by: Du Dolpher <dolpher.du@intel.com>
Edited to include sysmacros.h
Signed-off-by: Anuj Mittal <anuj.mittal@intel.com>
---
extlinux/Makefile | 3 +-
extlinux/main.c | 167 +-----------------------------------
libinstaller/syslinuxext.c | 171 +++++++++++++++++++++++++++++++++++++
3 files changed, 176 insertions(+), 165 deletions(-)
diff --git a/extlinux/Makefile b/extlinux/Makefile
index 1721ee5..62a4972 100644
--- a/extlinux/Makefile
+++ b/extlinux/Makefile
@@ -32,7 +32,8 @@ SRCS = main.c \
../libinstaller/advio.c \
../libinstaller/bootsect_bin.c \
../libinstaller/ldlinuxc32_bin.c \
- ../libinstaller/ldlinux_bin.c
+ ../libinstaller/ldlinux_bin.c \
+ ../libinstaller/syslinuxext.c
OBJS = $(patsubst %.c,%.o,$(notdir $(SRCS)))
.SUFFIXES: .c .o .i .s .S
diff --git a/extlinux/main.c b/extlinux/main.c
index ebff7ea..9add50f 100644
--- a/extlinux/main.c
+++ b/extlinux/main.c
@@ -62,6 +62,7 @@
#include "setadv.h"
#include "syslxopt.h" /* unified options */
#include "mountinfo.h"
+#include "syslinuxext.h"
#ifdef DEBUG
# define dprintf printf
@@ -69,10 +70,6 @@
# define dprintf(...) ((void)0)
#endif
-#ifndef EXT2_SUPER_OFFSET
-#define EXT2_SUPER_OFFSET 1024
-#endif
-
/* Since we have unused 2048 bytes in the primary AG of an XFS partition,
* we will use the first 0~512 bytes starting from 2048 for the Syslinux
* boot sector.
@@ -93,136 +90,6 @@ static char subvol[BTRFS_SUBVOL_MAX];
#define BTRFS_ADV_OFFSET (BTRFS_BOOT_AREA_A_OFFSET + BTRFS_BOOT_AREA_A_SIZE \
- 2*ADV_SIZE)
-/*
- * Get the size of a block device
- */
-static uint64_t get_size(int devfd)
-{
- uint64_t bytes;
- uint32_t sects;
- struct stat st;
-
-#ifdef BLKGETSIZE64
- if (!ioctl(devfd, BLKGETSIZE64, &bytes))
- return bytes;
-#endif
- if (!ioctl(devfd, BLKGETSIZE, &sects))
- return (uint64_t) sects << 9;
- else if (!fstat(devfd, &st) && st.st_size)
- return st.st_size;
- else
- return 0;
-}
-
-/*
- * Get device geometry and partition offset
- */
-struct geometry_table {
- uint64_t bytes;
- struct hd_geometry g;
-};
-
-static int sysfs_get_offset(int devfd, unsigned long *start)
-{
- struct stat st;
- char sysfs_name[128];
- FILE *f;
- int rv;
-
- if (fstat(devfd, &st))
- return -1;
-
- if ((size_t)snprintf(sysfs_name, sizeof sysfs_name,
- "/sys/dev/block/%u:%u/start",
- major(st.st_rdev), minor(st.st_rdev))
- >= sizeof sysfs_name)
- return -1;
-
- f = fopen(sysfs_name, "r");
- if (!f)
- return -1;
-
- rv = fscanf(f, "%lu", start);
- fclose(f);
-
- return (rv == 1) ? 0 : -1;
-}
-
-/* Standard floppy disk geometries, plus LS-120. Zipdisk geometry
- (x/64/32) is the final fallback. I don't know what LS-240 has
- as its geometry, since I don't have one and don't know anyone that does,
- and Google wasn't helpful... */
-static const struct geometry_table standard_geometries[] = {
- {360 * 1024, {2, 9, 40, 0}},
- {720 * 1024, {2, 9, 80, 0}},
- {1200 * 1024, {2, 15, 80, 0}},
- {1440 * 1024, {2, 18, 80, 0}},
- {1680 * 1024, {2, 21, 80, 0}},
- {1722 * 1024, {2, 21, 80, 0}},
- {2880 * 1024, {2, 36, 80, 0}},
- {3840 * 1024, {2, 48, 80, 0}},
- {123264 * 1024, {8, 32, 963, 0}}, /* LS120 */
- {0, {0, 0, 0, 0}}
-};
-
-int get_geometry(int devfd, uint64_t totalbytes, struct hd_geometry *geo)
-{
- struct floppy_struct fd_str;
- struct loop_info li;
- struct loop_info64 li64;
- const struct geometry_table *gp;
- int rv = 0;
-
- memset(geo, 0, sizeof *geo);
-
- if (!ioctl(devfd, HDIO_GETGEO, geo)) {
- goto ok;
- } else if (!ioctl(devfd, FDGETPRM, &fd_str)) {
- geo->heads = fd_str.head;
- geo->sectors = fd_str.sect;
- geo->cylinders = fd_str.track;
- geo->start = 0;
- goto ok;
- }
-
- /* Didn't work. Let's see if this is one of the standard geometries */
- for (gp = standard_geometries; gp->bytes; gp++) {
- if (gp->bytes == totalbytes) {
- memcpy(geo, &gp->g, sizeof *geo);
- goto ok;
- }
- }
-
- /* Didn't work either... assign a geometry of 64 heads, 32 sectors; this is
- what zipdisks use, so this would help if someone has a USB key that
- they're booting in USB-ZIP mode. */
-
- geo->heads = opt.heads ? : 64;
- geo->sectors = opt.sectors ? : 32;
- geo->cylinders = totalbytes / (geo->heads * geo->sectors << SECTOR_SHIFT);
- geo->start = 0;
-
- if (!opt.sectors && !opt.heads) {
- fprintf(stderr,
- "Warning: unable to obtain device geometry (defaulting to %d heads, %d sectors)\n"
- " (on hard disks, this is usually harmless.)\n",
- geo->heads, geo->sectors);
- rv = 1; /* Suboptimal result */
- }
-
-ok:
- /* If this is a loopback device, try to set the start */
- if (!ioctl(devfd, LOOP_GET_STATUS64, &li64))
- geo->start = li64.lo_offset >> SECTOR_SHIFT;
- else if (!ioctl(devfd, LOOP_GET_STATUS, &li))
- geo->start = (unsigned int)li.lo_offset >> SECTOR_SHIFT;
- else if (!sysfs_get_offset(devfd, &geo->start)) {
- /* OK */
- }
-
- return rv;
-}
-
/*
* Query the device geometry and put it into the boot sector.
* Map the file and put the map in the boot sector and file.
@@ -233,11 +100,8 @@ ok:
static int patch_file_and_bootblock(int fd, const char *dir, int devfd)
{
struct stat dirst, xdst;
- struct hd_geometry geo;
sector_t *sectp;
- uint64_t totalbytes, totalsectors;
int nsect;
- struct fat_boot_sector *sbs;
char *dirpath, *subpath, *xdirpath;
int rv;
@@ -281,33 +145,8 @@ static int patch_file_and_bootblock(int fd, const char *dir, int devfd)
/* Now subpath should contain the path relative to the fs base */
dprintf("subpath = %s\n", subpath);
- totalbytes = get_size(devfd);
- get_geometry(devfd, totalbytes, &geo);
-
- if (opt.heads)
- geo.heads = opt.heads;
- if (opt.sectors)
- geo.sectors = opt.sectors;
-
- /* Patch this into a fake FAT superblock. This isn't because
- FAT is a good format in any way, it's because it lets the
- early bootstrap share code with the FAT version. */
- dprintf("heads = %u, sect = %u\n", geo.heads, geo.sectors);
-
- sbs = (struct fat_boot_sector *)syslinux_bootsect;
-
- totalsectors = totalbytes >> SECTOR_SHIFT;
- if (totalsectors >= 65536) {
- set_16(&sbs->bsSectors, 0);
- } else {
- set_16(&sbs->bsSectors, totalsectors);
- }
- set_32(&sbs->bsHugeSectors, totalsectors);
-
- set_16(&sbs->bsBytesPerSec, SECTOR_SIZE);
- set_16(&sbs->bsSecPerTrack, geo.sectors);
- set_16(&sbs->bsHeads, geo.heads);
- set_32(&sbs->bsHiddenSecs, geo.start);
+ /* Patch syslinux_bootsect */
+ syslinux_patch_bootsect(devfd);
/* Construct the boot file map */
diff --git a/libinstaller/syslinuxext.c b/libinstaller/syslinuxext.c
index bb54cef..9ae8288 100644
--- a/libinstaller/syslinuxext.c
+++ b/libinstaller/syslinuxext.c
@@ -1,7 +1,178 @@
#define _GNU_SOURCE
+#include <sys/stat.h>
+#include <sys/types.h>
+#include <sys/sysmacros.h>
+#include <getopt.h>
+#include <ext2fs/ext2fs.h>
+
+#include "linuxioctl.h"
+#include "syslinux.h"
+#include "syslxint.h"
+#include "syslxopt.h"
+
+/*
+ * Get the size of a block device
+ */
+static uint64_t get_size(int dev_fd)
+{
+ uint64_t bytes;
+ uint32_t sects;
+ struct stat st;
+
+#ifdef BLKGETSIZE64
+ if (!ioctl(dev_fd, BLKGETSIZE64, &bytes))
+ return bytes;
+#endif
+ if (!ioctl(dev_fd, BLKGETSIZE, &sects))
+ return (uint64_t) sects << 9;
+ else if (!fstat(dev_fd, &st) && st.st_size)
+ return st.st_size;
+ else
+ return 0;
+}
+
+/*
+ * Get device geometry and partition offset
+ */
+static struct geometry_table {
+ uint64_t bytes;
+ struct hd_geometry g;
+};
+
+static int sysfs_get_offset(int dev_fd, unsigned long *start)
+{
+ struct stat st;
+ char sysfs_name[128];
+ FILE *f;
+ int rv;
+
+ if (fstat(dev_fd, &st))
+ return -1;
+
+ if ((size_t)snprintf(sysfs_name, sizeof sysfs_name,
+ "/sys/dev/block/%u:%u/start",
+ major(st.st_rdev), minor(st.st_rdev))
+ >= sizeof sysfs_name)
+ return -1;
+
+ f = fopen(sysfs_name, "r");
+ if (!f)
+ return -1;
+
+ rv = fscanf(f, "%lu", start);
+ fclose(f);
+
+ return (rv == 1) ? 0 : -1;
+}
+
+/* Standard floppy disk geometries, plus LS-120. Zipdisk geometry
+ (x/64/32) is the final fallback. I don't know what LS-240 has
+ as its geometry, since I don't have one and don't know anyone that does,
+ and Google wasn't helpful... */
+static const struct geometry_table standard_geometries[] = {
+ {360 * 1024, {2, 9, 40, 0}},
+ {720 * 1024, {2, 9, 80, 0}},
+ {1200 * 1024, {2, 15, 80, 0}},
+ {1440 * 1024, {2, 18, 80, 0}},
+ {1680 * 1024, {2, 21, 80, 0}},
+ {1722 * 1024, {2, 21, 80, 0}},
+ {2880 * 1024, {2, 36, 80, 0}},
+ {3840 * 1024, {2, 48, 80, 0}},
+ {123264 * 1024, {8, 32, 963, 0}}, /* LS120 */
+ {0, {0, 0, 0, 0}}
+};
+
+static int get_geometry(int dev_fd, uint64_t totalbytes, struct hd_geometry *geo)
+{
+ struct floppy_struct fd_str;
+ struct loop_info li;
+ struct loop_info64 li64;
+ const struct geometry_table *gp;
+ int rv = 0;
+
+ memset(geo, 0, sizeof *geo);
+
+ if (!ioctl(dev_fd, HDIO_GETGEO, geo)) {
+ goto ok;
+ } else if (!ioctl(dev_fd, FDGETPRM, &fd_str)) {
+ geo->heads = fd_str.head;
+ geo->sectors = fd_str.sect;
+ geo->cylinders = fd_str.track;
+ geo->start = 0;
+ goto ok;
+ }
+
+ /* Didn't work. Let's see if this is one of the standard geometries */
+ for (gp = standard_geometries; gp->bytes; gp++) {
+ if (gp->bytes == totalbytes) {
+ memcpy(geo, &gp->g, sizeof *geo);
+ goto ok;
+ }
+ }
+
+ /* Didn't work either... assign a geometry of 64 heads, 32 sectors; this is
+ what zipdisks use, so this would help if someone has a USB key that
+ they're booting in USB-ZIP mode. */
+
+ geo->heads = opt.heads ? : 64;
+ geo->sectors = opt.sectors ? : 32;
+ geo->cylinders = totalbytes / (geo->heads * geo->sectors << SECTOR_SHIFT);
+ geo->start = 0;
+
+ if (!opt.sectors && !opt.heads) {
+ fprintf(stderr,
+ "Warning: unable to obtain device geometry (defaulting to %d heads, %d sectors)\n"
+ " (on hard disks, this is usually harmless.)\n",
+ geo->heads, geo->sectors);
+ rv = 1; /* Suboptimal result */
+ }
+
+ok:
+ /* If this is a loopback device, try to set the start */
+ if (!ioctl(dev_fd, LOOP_GET_STATUS64, &li64))
+ geo->start = li64.lo_offset >> SECTOR_SHIFT;
+ else if (!ioctl(dev_fd, LOOP_GET_STATUS, &li))
+ geo->start = (unsigned int)li.lo_offset >> SECTOR_SHIFT;
+ else if (!sysfs_get_offset(dev_fd, &geo->start)) {
+ /* OK */
+ }
+
+ return rv;
+}
+
+
/* Patch syslinux_bootsect */
void syslinux_patch_bootsect(int dev_fd)
{
+ uint64_t totalbytes, totalsectors;
+ struct hd_geometry geo;
+ struct fat_boot_sector *sbs;
+
+ totalbytes = get_size(dev_fd);
+ get_geometry(dev_fd, totalbytes, &geo);
+
+ if (opt.heads)
+ geo.heads = opt.heads;
+ if (opt.sectors)
+ geo.sectors = opt.sectors;
+
+ /* Patch this into a fake FAT superblock. This isn't because
+ FAT is a good format in any way, it's because it lets the
+ early bootstrap share code with the FAT version. */
+ sbs = (struct fat_boot_sector *)syslinux_bootsect;
+
+ totalsectors = totalbytes >> SECTOR_SHIFT;
+ if (totalsectors >= 65536) {
+ set_16(&sbs->bsSectors, 0);
+ } else {
+ set_16(&sbs->bsSectors, totalsectors);
+ }
+ set_32(&sbs->bsHugeSectors, totalsectors);
+
+ set_16(&sbs->bsBytesPerSec, SECTOR_SIZE);
+ set_16(&sbs->bsSecPerTrack, geo.sectors);
+ set_16(&sbs->bsHeads, geo.heads);
+ set_32(&sbs->bsHiddenSecs, geo.start);
}

View File

@@ -0,0 +1,47 @@
From c28aae8bd381f77e66e6bac79761df7a484b054c Mon Sep 17 00:00:00 2001
From: Robert Yang <liezhi.yang@windriver.com>
Date: Fri, 2 Jan 2015 12:28:35 +0800
Subject: [PATCH] linux/syslinux: implement install_bootblock()
Refer to the install_bootblock() in extlinux/main.c to make
linux/syslinux.c's install_bootblock() which only supports ext2/3/4.
Upstream-Status: Submitted
Signed-off-by: Robert Yang <liezhi.yang@windriver.com>
Tested-by: Du Dolpher <dolpher.du@intel.com>
---
linux/syslinux.c | 20 ++++++++++++++++++++
1 file changed, 20 insertions(+)
diff --git a/linux/syslinux.c b/linux/syslinux.c
index 4e43921..93ed880 100755
--- a/linux/syslinux.c
+++ b/linux/syslinux.c
@@ -420,6 +420,26 @@ static int ext_file_write(ext2_file_t e2_file, const void *buf, size_t count,
*/
int install_bootblock(int fd, const char *device)
{
+ struct ext2_super_block sb;
+
+ if (xpread(fd, &sb, sizeof sb, EXT2_SUPER_OFFSET + opt.offset) != sizeof sb) {
+ perror("reading superblock");
+ return 1;
+ }
+
+ if (sb.s_magic != EXT2_SUPER_MAGIC) {
+ fprintf(stderr,
+ "no ext2/3/4 superblock found on %s\n", device);
+ return 1;
+ }
+
+ if (xpwrite(fd, syslinux_bootsect, syslinux_bootsect_len, 0)
+ != (signed)syslinux_bootsect_len) {
+ perror("writing bootblock");
+ return 1;
+ }
+
+ return 0;
}
/* The file's block count */

View File

@@ -0,0 +1,110 @@
From f2a5b64785958226c022cac9931b059b98f4e896 Mon Sep 17 00:00:00 2001
From: Merlin Mathesius <mmathesi@redhat.com>
Date: Wed, 13 May 2020 08:02:27 -0500
Subject: [PATCH] Workaround multiple definition of symbol errors
Lifted from Fedora https://src.fedoraproject.org/rpms/syslinux/blob/master/f/0005-Workaround-multiple-definition-of-symbol-errors.patch
Upstream-Status: Inactive-Upstream
Signed-off-by: Khem Raj <raj.khem@gmail.com>
---
com32/cmenu/Makefile | 2 +-
com32/elflink/ldlinux/Makefile | 2 +-
com32/gpllib/Makefile | 2 +-
com32/hdt/Makefile | 2 +-
core/Makefile | 2 +-
dos/Makefile | 2 +-
efi/Makefile | 2 +-
7 files changed, 7 insertions(+), 7 deletions(-)
diff --git a/com32/cmenu/Makefile b/com32/cmenu/Makefile
index b81b68e..2ae989c 100644
--- a/com32/cmenu/Makefile
+++ b/com32/cmenu/Makefile
@@ -49,7 +49,7 @@ makeoutputdirs:
@mkdir -p $(OBJ)/libmenu
libmenu/libmenu.elf: $(LIBMENU)
- $(LD) -shared $(LDFLAGS) -soname $(patsubst %.elf,%.c32,$(@F)) \
+ $(LD) -shared $(LDFLAGS) -z muldefs -soname $(patsubst %.elf,%.c32,$(@F)) \
-o $@ $^
tidy dist:
diff --git a/com32/elflink/ldlinux/Makefile b/com32/elflink/ldlinux/Makefile
index 87c0d36..2be2a01 100644
--- a/com32/elflink/ldlinux/Makefile
+++ b/com32/elflink/ldlinux/Makefile
@@ -33,7 +33,7 @@ endif
all: $(BTARGET) ldlinux_lnx.a
ldlinux.elf : $(OBJS)
- $(LD) $(LDFLAGS) -soname $(SONAME) -o $@ $^ $(LIBS)
+ $(LD) $(LDFLAGS) -z muldefs -soname $(SONAME) -o $@ $^ $(LIBS)
LNXCFLAGS += -D__export='__attribute__((visibility("default")))'
LNXLIBOBJS = get_key.lo
diff --git a/com32/gpllib/Makefile b/com32/gpllib/Makefile
index 1fec914..2d764d0 100644
--- a/com32/gpllib/Makefile
+++ b/com32/gpllib/Makefile
@@ -24,7 +24,7 @@ makeoutputdirs:
$(addprefix $(OBJ),$(sort $(dir $(LIBOBJS)))),$(b))
libgpl.elf : $(LIBOBJS)
- $(LD) -shared $(LDFLAGS) -soname $(patsubst %.elf,%.c32,$(@F)) -o $@ $^
+ $(LD) -shared $(LDFLAGS) -z muldefs -soname $(patsubst %.elf,%.c32,$(@F)) -o $@ $^
tidy dist clean:
find . \( -name \*.o -o -name .\*.d -o -name \*.tmp \) -print0 | \
diff --git a/com32/hdt/Makefile b/com32/hdt/Makefile
index 61736d0..1d94785 100644
--- a/com32/hdt/Makefile
+++ b/com32/hdt/Makefile
@@ -52,7 +52,7 @@ QEMU ?= qemu-kvm
all: $(MODULES) $(TESTFILES)
hdt.elf : $(OBJS) $(LIBS) $(C_LIBS)
- $(LD) $(LDFLAGS) -o $@ $^
+ $(LD) $(LDFLAGS) -z muldefs -o $@ $^
memtest:
-[ ! -f $(FLOPPY_DIR)/$(MEMTEST) ] && $(WGET) $(MEMTEST_URL) -O $(FLOPPY_DIR)/$(MEMTEST)
diff --git a/core/Makefile b/core/Makefile
index 50ff35a..f0a5562 100644
--- a/core/Makefile
+++ b/core/Makefile
@@ -156,7 +156,7 @@ LDSCRIPT = $(SRC)/$(ARCH)/syslinux.ld
NASM_ELF = elf
%.elf: %.o $(LIBDEP) $(LDSCRIPT) $(AUXLIBS)
- $(LD) $(LDFLAGS) -pie -Bsymbolic \
+ $(LD) $(LDFLAGS) -z muldefs -pie -Bsymbolic \
-T $(LDSCRIPT) \
--unresolved-symbols=report-all \
-E --hash-style=gnu -M -o $@ $< \
diff --git a/dos/Makefile b/dos/Makefile
index 4c930d1..5d1c72c 100644
--- a/dos/Makefile
+++ b/dos/Makefile
@@ -19,7 +19,7 @@ include $(MAKEDIR)/embedded.mk
CFLAGS += -D__MSDOS__ -mregparm=3 -DREGPARM=3
# CFLAGS += -DDEBUG
-LDFLAGS = -T $(SRC)/dosexe.ld
+LDFLAGS = -T $(SRC)/dosexe.ld -z muldefs
OPTFLAGS = -g
INCLUDES = -include code16.h -nostdinc -iwithprefix include \
-I$(SRC) -I$(SRC)/.. -I$(SRC)/../libfat \
diff --git a/efi/Makefile b/efi/Makefile
index f4501e7..72e081e 100644
--- a/efi/Makefile
+++ b/efi/Makefile
@@ -71,7 +71,7 @@ $(OBJS): | $(OBJ)/$(ARCH)
BTARGET = syslinux.efi
syslinux.so: $(OBJS) $(CORE_OBJS) $(LIB_OBJS)
- $(LD) $(LDFLAGS) --strip-debug -o $@ $^ -lgnuefi -lefi
+ $(LD) $(LDFLAGS) -z muldefs --strip-debug -o $@ $^ -lgnuefi -lefi
# We need to rename the .hash section because the EFI firmware
# linker really doesn't like it.

View File

@@ -0,0 +1,29 @@
From 66447f7c5c6996481ebd68ce8224d3de7525aad8 Mon Sep 17 00:00:00 2001
From: "H. Peter Anvin (Intel)" <hpa@zytor.com>
Date: Wed, 6 Feb 2019 11:30:51 -0800
Subject: [PATCH] install: don't install obsolete file com32.ld
com32.ld has been obsolete for a long time, and has been removed now;
don't install it either.
Reported-by: Joakim Tjernlund <Joakim.Tjernlund@infinera.com>
Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
Upstream-Status: Backport
Signed-off-by: Anuj Mittal <anuj.mittal@intel.com>
---
com32/lib/Makefile | 1 -
1 file changed, 1 deletion(-)
diff --git a/com32/lib/Makefile b/com32/lib/Makefile
index 74fff14..6a93149 100644
--- a/com32/lib/Makefile
+++ b/com32/lib/Makefile
@@ -113,7 +113,6 @@ spotless: clean
install: all
mkdir -m 755 -p $(INSTALLROOT)$(COM32DIR)
- install -m 644 $(SRC)/com32.ld $(INSTALLROOT)$(COM32DIR)
-rm -rf $(INSTALLROOT)$(COM32DIR)/include
cp -r $(SRC)/../include $(INSTALLROOT)$(COM32DIR)

View File

@@ -0,0 +1,56 @@
From 821d31148c07a8318277be32bc6a943c7fd2ba3f Mon Sep 17 00:00:00 2001
From: Martin Jansa <Martin.Jansa@gmail.com>
Date: Sat, 6 Aug 2022 11:53:55 +0000
Subject: [PATCH] libinstaller: Fix build with glibc-2.36
* add only necessary definitions from linux/fs.h, because including whole
causes conflicts with sys/mount.h:
http://errors.yoctoproject.org/Errors/Details/664535/
In file included from TOPDIR/tmp-glibc/work/core2-64-oe-linux/syslinux/6.04-pre2-r1/recipe-sysroot/usr/include/linux/fs.h:19,
from TOPDIR/tmp-glibc/work/core2-64-oe-linux/syslinux/6.04-pre2-r1/syslinux-6.04-pre2/linux/../libinstaller/linuxioctl.h:19,
from TOPDIR/tmp-glibc/work/core2-64-oe-linux/syslinux/6.04-pre2-r1/syslinux-6.04-pre2/linux/../libinstaller/syslxcom.c:34:
TOPDIR/tmp-glibc/work/core2-64-oe-linux/syslinux/6.04-pre2-r1/recipe-sysroot/usr/include/linux/mount.h:95:6: error: redeclaration of 'enum fsconfig_command'
95 | enum fsconfig_command {
| ^~~~~~~~~~~~~~~~
In file included from TOPDIR/tmp-glibc/work/core2-64-oe-linux/syslinux/6.04-pre2-r1/syslinux-6.04-pre2/linux/../libinstaller/syslxcom.c:31:
TOPDIR/tmp-glibc/work/core2-64-oe-linux/syslinux/6.04-pre2-r1/recipe-sysroot/usr/include/sys/mount.h:189:6: note: originally defined here
189 | enum fsconfig_command
| ^~~~~~~~~~~~~~~~
TOPDIR/tmp-glibc/work/core2-64-oe-linux/syslinux/6.04-pre2-r1/recipe-sysroot/usr/include/linux/mount.h:96:9: error: redeclaration of enumerator 'FSCONFIG_SET_FLAG'
96 | FSCONFIG_SET_FLAG = 0, /* Set parameter, supplying no value */
| ^~~~~~~~~~~~~~~~~
...
Upstream-Status: Inactive-Upstream
Signed-off-by: Martin Jansa <Martin.Jansa@gmail.com>
---
libinstaller/linuxioctl.h | 15 ++++++++++++++-
1 file changed, 14 insertions(+), 1 deletion(-)
diff --git a/libinstaller/linuxioctl.h b/libinstaller/linuxioctl.h
index e2731c7..f4a6703 100644
--- a/libinstaller/linuxioctl.h
+++ b/libinstaller/linuxioctl.h
@@ -16,7 +16,20 @@
#include <linux/fd.h> /* Floppy geometry */
#include <linux/hdreg.h> /* Hard disk geometry */
-#include <linux/fs.h> /* FIGETBSZ, FIBMAP, FS_IOC_* */
+// #include <linux/fs.h> /* FIGETBSZ, FIBMAP, FS_IOC_* */
+// linux/fs.h unfortunately causes conflict with sys/mount.h since glibc-2.36
+// https://sourceware.org/glibc/wiki/Release/2.36#Usage_of_.3Clinux.2Fmount.h.3E_and_.3Csys.2Fmount.h.3E
+// add the necessary definitions
+
+#define FS_IOC_GETFLAGS _IOR('f', 1, long)
+#define FS_IOC_SETFLAGS _IOW('f', 2, long)
+#define FIBMAP _IO(0x00,1) /* bmap access */
+#define FIGETBSZ _IO(0x00,2) /* get the block size used for bmap */
+#define FS_IMMUTABLE_FL 0x00000010 /* Immutable file */
+#define BLKGETSIZE _IO(0x12,96) /* return device size /512 (long *arg) */
+
+// for musl we also need limits.h for PATH_MAX
+#include <linux/limits.h>
#undef SECTOR_SIZE /* Defined in msdos_fs.h for no good reason */
#undef SECTOR_BITS

View File

@@ -0,0 +1,27 @@
From a11c8f88de6b6c42c805ba76e70532977bfd24bf Mon Sep 17 00:00:00 2001
From: Saul Wold <sgw@linux.intel.com>
Date: Wed, 10 Dec 2014 10:26:33 -0800
Subject: [PATCH] remove clean script
This script try to call git submodule, since we are downloading
the tarball it seems in-correct to do this.
Upstream-Status: Inappropriate [OE-Specific]
Signed-off-by: Saul Wold <sgw@linux.intel.com>
Signed-off-by: Martin Jansa <Martin.Jansa@gmail.com>
---
efi/Makefile | 1 -
1 file changed, 1 deletion(-)
diff --git a/efi/Makefile b/efi/Makefile
index 72e081e..3cfb3f6 100644
--- a/efi/Makefile
+++ b/efi/Makefile
@@ -102,7 +102,6 @@ tidy dist:
rm -f *.so *.o wrapper
find . \( -name \*.o -o -name \*.a -o -name .\*.d -o -name \*.tmp \) -print0 | \
xargs -0r rm -f
- $(topdir)/efi/clean-gnu-efi.sh $(EFI_SUBARCH) $(objdir)
clean: tidy

View File

@@ -0,0 +1,32 @@
From e49e86bd3199f51ada8a4a1d51aa8d627645279e Mon Sep 17 00:00:00 2001
From: Richard Purdie <richard.purdie@linuxfoundation.org>
Date: Sat, 27 Feb 2021 23:42:03 +0000
Subject: [PATCH] Fix reproducibility issues
In order to build deterministic binaries, we need to sort the wildcard expansion
so the libraries are linked in the same order each time. This fixes reproducibility
issues within syslinux builds.
Upstream-Status: Inactive-Upstream
RP 2021/3/1
Signed-off-by: Martin Jansa <Martin.Jansa@gmail.com>
---
mk/lib.mk | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/mk/lib.mk b/mk/lib.mk
index f3fb07c..815698c 100644
--- a/mk/lib.mk
+++ b/mk/lib.mk
@@ -130,8 +130,8 @@ LIBENTRY_OBJS = \
exit.o
LIBGCC_OBJS = \
- $(patsubst $(com32)/lib/%.c,%.o,$(wildcard $(com32)/lib/$(ARCH)/libgcc/*.c)) \
- $(patsubst $(com32)/lib/%.S,%.o,$(wildcard $(com32)/lib/$(ARCH)/libgcc/*.S))
+ $(sort $(patsubst $(com32)/lib/%.c,%.o,$(wildcard $(com32)/lib/$(ARCH)/libgcc/*.c))) \
+ $(sort $(patsubst $(com32)/lib/%.S,%.o,$(wildcard $(com32)/lib/$(ARCH)/libgcc/*.S)))
LIBCONSOLE_OBJS = \
\

View File

@@ -0,0 +1,131 @@
SUMMARY = "Multi-purpose linux bootloader"
HOMEPAGE = "http://www.syslinux.org/"
DESCRIPTION = "The Syslinux Project covers lightweight bootloaders for MS-DOS FAT filesystems (SYSLINUX), network booting (PXELINUX), bootable "El Torito" CD-ROMs (ISOLINUX), and Linux ext2/ext3/ext4 or btrfs filesystems (EXTLINUX). The project also includes MEMDISK, a tool to boot legacy operating systems (such as DOS) from nontraditional media; it is usually used in conjunction with PXELINUX and ISOLINUX."
LICENSE = "GPL-2.0-or-later"
LIC_FILES_CHKSUM = "file://COPYING;md5=0636e73ff0215e8d672dc4c32c317bb3 \
file://README;beginline=35;endline=41;md5=558f2c71cb1fb9ba511ccd4858e48e8a"
DEPENDS = "nasm-native util-linux e2fsprogs"
SRC_URI = "https://www.zytor.com/pub/syslinux/Testing/6.04/syslinux-${PV}.tar.xz \
file://0001-linux-syslinux-support-ext2-3-4-device.patch \
file://0002-linux-syslinux-implement-open_ext2_fs.patch \
file://0003-linux-syslinux-implement-install_to_ext2.patch \
file://0004-linux-syslinux-add-ext_file_read-and-ext_file_write.patch \
file://0005-linux-syslinux-implement-handle_adv_on_ext.patch \
file://0006-linux-syslinux-implement-write_to_ext-and-add-syslin.patch \
file://0007-linux-syslinux-implement-ext_construct_sectmap_fs.patch \
file://0008-libinstaller-syslinuxext-implement-syslinux_patch_bo.patch \
file://0009-linux-syslinux-implement-install_bootblock.patch \
file://0010-Workaround-multiple-definition-of-symbol-errors.patch \
file://0011-install-don-t-install-obsolete-file-com32.ld.patch \
file://0012-libinstaller-Fix-build-with-glibc-2.36.patch \
file://0013-remove-clean-script.patch \
file://0014-Fix-reproducibility-issues.patch \
"
SRC_URI[md5sum] = "2b31c78f087f99179feb357da312d7ec"
SRC_URI[sha256sum] = "4441a5d593f85bb6e8d578cf6653fb4ec30f9e8f4a2315a3d8f2d0a8b3fadf94"
# remove at next version upgrade or when output changes
RECIPE_NO_UPDATE_REASON = "6.04-pre3 is broken"
UPSTREAM_CHECK_URI = "https://www.zytor.com/pub/syslinux/"
UPSTREAM_CHECK_REGEX = "syslinux-(?P<pver>.+)\.tar"
UPSTREAM_VERSION_UNKNOWN = "1"
# We can build the native parts anywhere, but the target has to be x86
COMPATIBLE_HOST:class-target = '(x86_64|i.86).*-(linux|freebsd.*)'
# Don't let the sanity checker trip on the 32 bit real mode BIOS binaries
INSANE_SKIP:${PN}-misc = "arch"
INSANE_SKIP:${PN}-chain = "arch"
# When building the installer, CC is used to link. When building the bootloader,
# LD is used. However, these variables assume that GCC is used and break the
# build, so unset them.
TARGET_LDFLAGS = ""
SECURITY_LDFLAGS = ""
LDFLAGS_SECTION_REMOVAL = ""
CFLAGS:append = " -DNO_INLINE_FUNCS -Wno-error=implicit-function-declaration"
EXTRA_OEMAKE = " \
BINDIR=${bindir} SBINDIR=${sbindir} LIBDIR=${libdir} \
DATADIR=${datadir} MANDIR=${mandir} INCDIR=${includedir} \
CC="${CC} ${CFLAGS} ${LDFLAGS}" \
LD="${LD} ${LDFLAGS}" \
OBJDUMP="${OBJDUMP}" \
OBJCOPY="${OBJCOPY}" \
AR="${AR}" \
STRIP="${STRIP}" \
NM="${NM}" \
RANLIB="${RANLIB}" \
"
# mtools allows non-root users to install syslinux
PACKAGECONFIG ??= "mtools"
PACKAGECONFIG[mtools] = ",,,"
#
# Tasks for native/nativesdk which just build the installer.
#
do_configure() {
oe_runmake firmware="bios" clean
}
do_compile() {
oe_runmake firmware="bios" installer
}
do_install() {
install -d ${D}${bindir}
install \
${B}/bios/extlinux/extlinux \
${B}/bios/utils/isohybrid \
${D}${bindir}
if ${@bb.utils.contains("PACKAGECONFIG", "mtools", "true", "false", d)}; then
install ${B}/bios/mtools/syslinux ${D}${bindir}
else
install ${B}/bios/linux/syslinux ${D}${bindir}
fi
}
#
# Tasks for target which ship the precompiled bootloader and installer
#
do_configure:class-target() {
# No need to do anything as we're mostly shipping the precompiled binaries
:
}
do_compile:class-target() {
# No need to do anything as we're mostly shipping the precompiled binaries
:
}
do_install:class-target() {
oe_runmake firmware="bios" install INSTALLROOT="${D}"
install -d ${D}${datadir}/syslinux/
install -m 644 ${S}/bios/core/ldlinux.sys ${D}${datadir}/syslinux/
install -m 644 ${S}/bios/core/ldlinux.bss ${D}${datadir}/syslinux/
}
PACKAGES += "${PN}-extlinux ${PN}-mbr ${PN}-chain ${PN}-pxelinux ${PN}-isolinux ${PN}-misc"
RDEPENDS:${PN} += "${@bb.utils.contains("PACKAGECONFIG", "mtools", "mtools", "", d)}"
RDEPENDS:${PN}-misc += "perl"
FILES:${PN} = "${bindir}/syslinux"
FILES:${PN}-extlinux = "${sbindir}/extlinux"
FILES:${PN}-mbr = "${datadir}/${BPN}/mbr.bin"
FILES:${PN}-chain = "${datadir}/${BPN}/chain.c32"
FILES:${PN}-isolinux = "${datadir}/${BPN}/isolinux.bin"
FILES:${PN}-pxelinux = "${datadir}/${BPN}/pxelinux.0"
FILES:${PN}-dev += "${datadir}/${BPN}/com32/lib*${SOLIBS} ${datadir}/${BPN}/com32/include ${datadir}/${BPN}/com32/com32.ld"
FILES:${PN}-staticdev += "${datadir}/${BPN}/com32/lib*.a ${libdir}/${BPN}/com32/lib*.a"
FILES:${PN}-misc = "${datadir}/${BPN}/* ${libdir}/${BPN}/* ${bindir}/*"
BBCLASSEXTEND = "native nativesdk"