]> xenbits.xensource.com Git - people/royger/xen.git/commitdiff
x86/livepatch: Fail the build if duplicate symbols exist
authorRoss Lagerwall <ross.lagerwall@citrix.com>
Thu, 4 Feb 2016 16:40:56 +0000 (16:40 +0000)
committerAndrew Cooper <andrew.cooper3@citrix.com>
Wed, 30 Oct 2019 13:07:25 +0000 (13:07 +0000)
The binary diffing algorithm used by xen-livepatch depends on having unique
symbols.

The livepatch loading algorithm used by Xen resolves relocations by symbol
name, and thus also depends on having unique symbols.

Introduce CONFIG_ENFORCE_UNIQUE_SYMBOLS to control failing the build if
duplicate symbols are found, and disable it in the RANDCONFIG build.

Signed-off-by: Ross Lagerwall <ross.lagerwall@citrix.com>
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Release-acked-by: Juergen Gross <jgross@suse.com>
xen/arch/x86/Makefile
xen/common/Kconfig
xen/tools/kconfig/allrandom.config
xen/tools/symbols.c

index 2443fd2cc5bd227be0634c3138832d5cff5df3b3..6b369f21cbf59fac4793a2d144be117e2fb9287a 100644 (file)
@@ -99,6 +99,7 @@ endif
 
 syms-warn-dup-y := --warn-dup
 syms-warn-dup-$(CONFIG_SUPPRESS_DUPLICATE_SYMBOL_WARNINGS) :=
+syms-warn-dup-$(CONFIG_ENFORCE_UNIQUE_SYMBOLS) := --error-dup
 
 $(TARGET): TMP = $(@D)/.$(@F).elf32
 $(TARGET): $(TARGET)-syms $(efi-y) boot/mkelf32
index fddb6c170770168d96efa4d028b72bfdbc827572..f75474197273bcdf641fd959c4bdf31d6abd3cf2 100644 (file)
@@ -371,9 +371,24 @@ config FAST_SYMBOL_LOOKUP
 
          If unsure, say Y.
 
+config ENFORCE_UNIQUE_SYMBOLS
+       bool "Enforce unique symbols"
+       default y
+       depends on LIVEPATCH
+       ---help---
+         Multiple symbols with the same name aren't generally a problem
+         unless livepatching is to be used.
+
+         Livepatch loading involves resolving relocations against symbol
+         names, and attempting to a duplicate symbol in a livepatch will
+         result in incorrect livepatch application.
+
+         This option should be used to ensure that a build of Xen can have a
+         livepatch build and apply correctly.
+
 config SUPPRESS_DUPLICATE_SYMBOL_WARNINGS
-       bool "Suppress duplicate symbol warnings" if !LIVEPATCH
-       default y if !LIVEPATCH
+       bool "Suppress duplicate symbol warnings" if !ENFORCE_UNIQUE_SYMBOLS
+       default y if !ENFORCE_UNIQUE_SYMBOLS
        ---help---
          Multiple symbols with the same name aren't generally a problem
          unless Live patching is to be used, so these warnings can be
index 76f74320b5b07eb9b5bf9e299ad070b7385ee536..c480896b967c1e2a945e4710ca341c25306a5b6b 100644 (file)
@@ -2,3 +2,4 @@
 
 CONFIG_GCOV_FORMAT_AUTODETECT=y
 CONFIG_UBSAN=n
+CONFIG_ENFORCE_UNIQUE_SYMBOLS=n
index 05139d1600ac74634fba61968761d0e8af9b6b9e..9f9e2c99006120d7d84c973b627c9f4e42094fcb 100644 (file)
@@ -599,7 +599,7 @@ static int compare_name(const void *p1, const void *p2)
 int main(int argc, char **argv)
 {
        unsigned int i;
-       bool unsorted = false, warn_dup = false;
+       bool unsorted = false, warn_dup = false, error_dup = false, found_dup = false;
 
        if (argc >= 2) {
                for (i = 1; i < argc; i++) {
@@ -619,6 +619,8 @@ int main(int argc, char **argv)
                                sort_by_name = 1;
                        else if (strcmp(argv[i], "--warn-dup") == 0)
                                warn_dup = true;
+                       else if (strcmp(argv[i], "--error-dup") == 0)
+                               warn_dup = error_dup = true;
                        else if (strcmp(argv[i], "--xensyms") == 0)
                                map_only = true;
                        else
@@ -634,14 +636,19 @@ int main(int argc, char **argv)
                for (i = 1; i < table_cnt; ++i)
                        if (strcmp(SYMBOL_NAME(table + i - 1),
                                   SYMBOL_NAME(table + i)) == 0 &&
-                           table[i - 1].addr != table[i].addr)
+                           table[i - 1].addr != table[i].addr) {
                                fprintf(stderr,
                                        "Duplicate symbol '%s' (%llx != %llx)\n",
                                        SYMBOL_NAME(table + i),
                                        table[i].addr, table[i - 1].addr);
+                               found_dup = true;
+                       }
                unsorted = true;
        }
 
+       if (error_dup && found_dup)
+               exit(1);
+
        if (unsorted)
                qsort(table, table_cnt, sizeof(*table), compare_value);