From 508ed0e02b5e62b284275c22c4752c2b972d0249 Mon Sep 17 00:00:00 2001 From: John Ousterhout Date: Thu, 26 Mar 2020 11:28:48 -0700 Subject: [PATCH] Fix link errors with GCC 10 and binutils 2.34 on Fedora Fix the following compile errors: ld: ... multiple definition of `fs_device'; ... first defined here and ld: ... multiple definition of `test_name'; ... first defined here. These seem to result in a change in how GCC and the linker handle strong and weak symbols. Signed-off-by: W. Michael Petullo --- src/filesys/filesys.h | 2 +- src/tests/filesys/base/child-syn-read.c | 3 +-- src/tests/filesys/extended/child-syn-rw.c | 3 +-- src/tests/userprog/child-close.c | 4 ++-- src/tests/userprog/child-rox.c | 4 ++-- src/tests/userprog/child-simple.c | 4 ++-- src/tests/userprog/multi-recurse.c | 4 ++-- src/tests/userprog/no-vm/multi-oom.c | 4 ++-- src/tests/vm/child-linear.c | 4 ++-- src/tests/vm/child-qsort-mm.c | 3 +-- src/tests/vm/child-qsort.c | 3 +-- src/tests/vm/child-sort.c | 3 +-- 12 files changed, 18 insertions(+), 23 deletions(-) diff --git a/src/filesys/filesys.h b/src/filesys/filesys.h index c1cda84..455ac72 100644 --- a/src/filesys/filesys.h +++ b/src/filesys/filesys.h @@ -9,7 +9,7 @@ #define ROOT_DIR_SECTOR 1 /* Root directory file inode sector. */ /* Block device that contains the file system. */ -struct block *fs_device; +extern struct block *fs_device; void filesys_init (bool format); void filesys_done (void); diff --git a/src/tests/filesys/base/child-syn-read.c b/src/tests/filesys/base/child-syn-read.c index 77a5e26..27ee59d 100644 --- a/src/tests/filesys/base/child-syn-read.c +++ b/src/tests/filesys/base/child-syn-read.c @@ -11,8 +11,6 @@ #include "tests/lib.h" #include "tests/filesys/base/syn-read.h" -const char *test_name = "child-syn-read"; - static char buf[BUF_SIZE]; int @@ -22,6 +20,7 @@ main (int argc, const char *argv[]) int fd; size_t i; + test_name = "child-syn-read"; quiet = true; CHECK (argc == 2, "argc must be 2, actually %d", argc); diff --git a/src/tests/filesys/extended/child-syn-rw.c b/src/tests/filesys/extended/child-syn-rw.c index 0e2217d..d456a3a 100644 --- a/src/tests/filesys/extended/child-syn-rw.c +++ b/src/tests/filesys/extended/child-syn-rw.c @@ -13,8 +13,6 @@ #include "tests/filesys/extended/syn-rw.h" #include "tests/lib.h" -const char *test_name = "child-syn-rw"; - static char buf1[BUF_SIZE]; static char buf2[BUF_SIZE]; @@ -25,6 +23,7 @@ main (int argc, const char *argv[]) int fd; size_t ofs; + test_name = "child-syn-rw"; quiet = true; CHECK (argc == 2, "argc must be 2, actually %d", argc); diff --git a/src/tests/userprog/child-close.c b/src/tests/userprog/child-close.c index ac948c8..866e159 100644 --- a/src/tests/userprog/child-close.c +++ b/src/tests/userprog/child-close.c @@ -13,11 +13,11 @@ #include #include "tests/lib.h" -const char *test_name = "child-close"; - int main (int argc UNUSED, char *argv[]) { + test_name = "child-close"; + msg ("begin"); if (!isdigit (*argv[1])) fail ("bad command-line arguments"); diff --git a/src/tests/userprog/child-rox.c b/src/tests/userprog/child-rox.c index aba808b..6fb2fc9 100644 --- a/src/tests/userprog/child-rox.c +++ b/src/tests/userprog/child-rox.c @@ -10,8 +10,6 @@ #include #include "tests/lib.h" -const char *test_name = "child-rox"; - static void try_write (void) { @@ -31,6 +29,8 @@ try_write (void) int main (int argc UNUSED, char *argv[]) { + test_name = "child-rox"; + msg ("begin"); try_write (); diff --git a/src/tests/userprog/child-simple.c b/src/tests/userprog/child-simple.c index 0d2dacf..06cce89 100644 --- a/src/tests/userprog/child-simple.c +++ b/src/tests/userprog/child-simple.c @@ -5,11 +5,11 @@ #include #include "tests/lib.h" -const char *test_name = "child-simple"; - int main (void) { + test_name = "child-simple"; + msg ("run"); return 81; } diff --git a/src/tests/userprog/multi-recurse.c b/src/tests/userprog/multi-recurse.c index 7172ec3..fcd592b 100644 --- a/src/tests/userprog/multi-recurse.c +++ b/src/tests/userprog/multi-recurse.c @@ -7,13 +7,13 @@ #include #include "tests/lib.h" -const char *test_name = "multi-recurse"; - int main (int argc UNUSED, char *argv[]) { int n = atoi (argv[1]); + test_name = "multi-recurse"; + msg ("begin %d", n); if (n != 0) { diff --git a/src/tests/userprog/no-vm/multi-oom.c b/src/tests/userprog/no-vm/multi-oom.c index cd2c939..be0668a 100644 --- a/src/tests/userprog/no-vm/multi-oom.c +++ b/src/tests/userprog/no-vm/multi-oom.c @@ -27,8 +27,6 @@ static const int EXPECTED_DEPTH_TO_PASS = 30; static const int EXPECTED_REPETITIONS = 10; -const char *test_name = "multi-oom"; - enum child_termination_mode { RECURSE, CRASH }; /* Spawn a recursive copy of ourselves, passing along instructions @@ -107,6 +105,8 @@ main (int argc, char *argv[]) { int n; + test_name = "multi-oom"; + n = argc > 1 ? atoi (argv[1]) : 0; bool is_at_root = (n == 0); if (is_at_root) diff --git a/src/tests/vm/child-linear.c b/src/tests/vm/child-linear.c index eca3e3f..cdbe82e 100644 --- a/src/tests/vm/child-linear.c +++ b/src/tests/vm/child-linear.c @@ -7,8 +7,6 @@ #include "tests/lib.h" #include "tests/main.h" -const char *test_name = "child-linear"; - #define SIZE (1024 * 1024) static char buf[SIZE]; @@ -19,6 +17,8 @@ main (int argc, char *argv[]) struct arc4 arc4; size_t i; + test_name = "child-linear"; + /* Encrypt zeros. */ arc4_init (&arc4, key, strlen (key)); arc4_crypt (&arc4, buf, SIZE); diff --git a/src/tests/vm/child-qsort-mm.c b/src/tests/vm/child-qsort-mm.c index db45499..8d9549d 100644 --- a/src/tests/vm/child-qsort-mm.c +++ b/src/tests/vm/child-qsort-mm.c @@ -7,14 +7,13 @@ #include "tests/main.h" #include "tests/vm/qsort.h" -const char *test_name = "child-qsort-mm"; - int main (int argc UNUSED, char *argv[]) { int handle; unsigned char *p = (unsigned char *) 0x10000000; + test_name = "child-qsort-mm"; quiet = true; CHECK ((handle = open (argv[1])) > 1, "open \"%s\"", argv[1]); diff --git a/src/tests/vm/child-qsort.c b/src/tests/vm/child-qsort.c index 355f4eb..e243704 100644 --- a/src/tests/vm/child-qsort.c +++ b/src/tests/vm/child-qsort.c @@ -9,8 +9,6 @@ #include "tests/main.h" #include "tests/vm/qsort.h" -const char *test_name = "child-qsort"; - int main (int argc UNUSED, char *argv[]) { @@ -18,6 +16,7 @@ main (int argc UNUSED, char *argv[]) unsigned char buf[128 * 1024]; size_t size; + test_name = "child-qsort"; quiet = true; CHECK ((handle = open (argv[1])) > 1, "open \"%s\"", argv[1]); diff --git a/src/tests/vm/child-sort.c b/src/tests/vm/child-sort.c index dff2c77..2b13b67 100644 --- a/src/tests/vm/child-sort.c +++ b/src/tests/vm/child-sort.c @@ -7,8 +7,6 @@ #include "tests/lib.h" #include "tests/main.h" -const char *test_name = "child-sort"; - unsigned char buf[128 * 1024]; size_t histogram[256]; @@ -20,6 +18,7 @@ main (int argc UNUSED, char *argv[]) size_t size; size_t i; + test_name = "child-sort"; quiet = true; CHECK ((handle = open (argv[1])) > 1, "open \"%s\"", argv[1]); -- 2.30.2