From b3965a9e8a9b195e5ed958c1a3f8cfa4b26d620a Mon Sep 17 00:00:00 2001 From: Nadav Har'El Date: Mon, 14 Jun 2021 09:20:52 +0300 Subject: [PATCH] fs/vfs/main.cc: fix gcc 11 build error In fs/vfs/main.cc we have bootfs_start, which was defined as a single character (extern char bootfs_start) but was really treated as the beginning of a longer memory area. Gcc 11 can recognize that we access beyond this single character, and fail the compilation. To work around this problem, we declare bootfs_start as extern char bootfs_start[] Little needs to be changed besides this - except changing &bootfs_start + offset - which gcc doesn't like, to &bootfs_start[offset]. Signed-off-by: Nadav Har'El Message-Id: <20210614062057.1998552-8-nyh@scylladb.com> --- fs/vfs/main.cc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/fs/vfs/main.cc b/fs/vfs/main.cc index 71110796bf..b411da6035 100644 --- a/fs/vfs/main.cc +++ b/fs/vfs/main.cc @@ -2197,7 +2197,7 @@ struct bootfs_metadata { char name[BOOTFS_PATH_MAX]; }; -extern char bootfs_start; +extern char bootfs_start[]; int ramfs_set_file_data(struct vnode *vp, const void *data, size_t size); void unpack_bootfs(void) @@ -2223,7 +2223,7 @@ void unpack_bootfs(void) if (md[i].type == bootfs_file_type::symlink) { // This is a symbolic link record. The file's content is the // target path, and we assume ends with a null. - if (symlink(&bootfs_start + md[i].offset, md[i].name) != 0) { + if (symlink(&bootfs_start[md[i].offset], md[i].name) != 0) { kprintf("couldn't symlink %s: %d\n", md[i].name, errno); sys_panic("unpack_bootfs failed"); } @@ -2250,7 +2250,7 @@ void unpack_bootfs(void) } struct vnode *vp = fp->f_dentry->d_vnode; - ret = ramfs_set_file_data(vp, &bootfs_start + md[i].offset, md[i].size); + ret = ramfs_set_file_data(vp, &bootfs_start[md[i].offset], md[i].size); if (ret) { kprintf("ramfs_set_file_data failed, ret = %d\n", ret); sys_panic("unpack_bootfs failed");