]> xenbits.xensource.com Git - people/aperard/xen-unstable.git/commitdiff
work around Clang generating .data.rel.ro section for init-only files
authorAndrew Cooper <andrew.cooper3@citrix.com>
Thu, 25 Feb 2016 12:01:01 +0000 (13:01 +0100)
committerJan Beulich <jbeulich@suse.com>
Thu, 25 Feb 2016 12:01:01 +0000 (13:01 +0100)
Clang-3.8 generates several .data.rel.ro sections when compiling Xen.  As
these contain no global symbols, they should be .data.rel.ro.local.  This
breaks the SPECIAL_DATA_SECTIONS check when converting the transition units to
being init-only.

For alternatives.c, explicitly move the nops arrays into __initconst.  For efi
boot.c, manually create the optimisation performed by Clang by collapsing the
switch statement into a lookup table.  The double use of const is required to
avoid breaking the ARM build by creating a section type conflict with
fdt_guid.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
xen/arch/arm/xen.lds.S
xen/arch/x86/alternative.c
xen/arch/x86/xen.lds.S
xen/common/efi/boot.c
xen/include/xen/init.h

index f501a2fd013f75609f63d37a90bedfa12be0fb01..9f7f915c518478b1a5ee2bb13acf7d97bd5d6f5e 100644 (file)
@@ -114,6 +114,7 @@ SECTIONS
   . = ALIGN(PAGE_SIZE);
   .init.data : {
        *(.init.rodata)
+       *(.init.rodata.rel)
        *(.init.rodata.str*)
        *(.init.data)
        *(.init.data.rel)
index 46ac0fdc6527b5f08b02c9f8f396f59ed93ad8a8..9d54df1e52f9921a6e65a405d568e272b5f7c59b 100644 (file)
@@ -38,7 +38,7 @@ static const unsigned char k8nops[] __initconst = {
     K8_NOP7,
     K8_NOP8
 };
-static const unsigned char * const k8_nops[ASM_NOP_MAX+1] = {
+static const unsigned char * const k8_nops[ASM_NOP_MAX+1] __initconstrel = {
     NULL,
     k8nops,
     k8nops + 1,
@@ -62,7 +62,7 @@ static const unsigned char p6nops[] __initconst = {
     P6_NOP7,
     P6_NOP8
 };
-static const unsigned char * const p6_nops[ASM_NOP_MAX+1] = {
+static const unsigned char * const p6_nops[ASM_NOP_MAX+1] __initconstrel = {
     NULL,
     p6nops,
     p6nops + 1,
index 9fde1dbffb3df3cc7b3d990b0b9f9cf59834b471..b3eb20719f1035c1483cbc882dcf1b59985883b8 100644 (file)
@@ -119,6 +119,7 @@ SECTIONS
   } :text
   .init.data : {
        *(.init.rodata)
+       *(.init.rodata.rel)
        *(.init.rodata.str*)
        *(.init.data)
        *(.init.data.rel)
index 53c7452e5087535ffe9573e7a34e727058ac7434..125c9ce64ada5cde37f229efba0f57d48a5ab400 100644 (file)
@@ -241,53 +241,33 @@ static void __init noreturn blexit(const CHAR16 *str)
 /* generic routine for printing error messages */
 static void __init PrintErrMesg(const CHAR16 *mesg, EFI_STATUS ErrCode)
 {
+    static const CHAR16* const ErrCodeToStr[] __initconstrel = {
+        [~EFI_ERROR_MASK & EFI_NOT_FOUND]           = L"Not found",
+        [~EFI_ERROR_MASK & EFI_NO_MEDIA]            = L"The device has no media",
+        [~EFI_ERROR_MASK & EFI_MEDIA_CHANGED]       = L"Media changed",
+        [~EFI_ERROR_MASK & EFI_DEVICE_ERROR]        = L"Device error",
+        [~EFI_ERROR_MASK & EFI_VOLUME_CORRUPTED]    = L"Volume corrupted",
+        [~EFI_ERROR_MASK & EFI_ACCESS_DENIED]       = L"Access denied",
+        [~EFI_ERROR_MASK & EFI_OUT_OF_RESOURCES]    = L"Out of resources",
+        [~EFI_ERROR_MASK & EFI_VOLUME_FULL]         = L"Volume is full",
+        [~EFI_ERROR_MASK & EFI_SECURITY_VIOLATION]  = L"Security violation",
+        [~EFI_ERROR_MASK & EFI_CRC_ERROR]           = L"CRC error",
+        [~EFI_ERROR_MASK & EFI_COMPROMISED_DATA]    = L"Compromised data",
+        [~EFI_ERROR_MASK & EFI_BUFFER_TOO_SMALL]    = L"Buffer too small",
+    };
+    EFI_STATUS ErrIdx = ErrCode & ~EFI_ERROR_MASK;
+
     StdOut = StdErr;
     PrintErr((CHAR16 *)mesg);
     PrintErr(L": ");
 
-    switch (ErrCode)
+    if( (ErrIdx < ARRAY_SIZE(ErrCodeToStr)) && ErrCodeToStr[ErrIdx] )
+        mesg = ErrCodeToStr[ErrIdx];
+    else
     {
-    case EFI_NOT_FOUND:
-        mesg = L"Not found";
-        break;
-    case EFI_NO_MEDIA:
-        mesg = L"The device has no media";
-        break;
-    case EFI_MEDIA_CHANGED:
-        mesg = L"Media changed";
-        break;
-    case EFI_DEVICE_ERROR:
-        mesg = L"Device error";
-        break;
-    case EFI_VOLUME_CORRUPTED:
-        mesg = L"Volume corrupted";
-        break;
-    case EFI_ACCESS_DENIED:
-        mesg = L"Access denied";
-        break;
-    case EFI_OUT_OF_RESOURCES:
-        mesg = L"Out of resources";
-        break;
-    case EFI_VOLUME_FULL:
-        mesg = L"Volume is full";
-        break;
-    case EFI_SECURITY_VIOLATION:
-        mesg = L"Security violation";
-        break;
-    case EFI_CRC_ERROR:
-        mesg = L"CRC error";
-        break;
-    case EFI_COMPROMISED_DATA:
-        mesg = L"Compromised data";
-        break;
-    case EFI_BUFFER_TOO_SMALL:
-        mesg = L"Buffer too small";
-        break;
-    default:
         PrintErr(L"ErrCode: ");
         DisplayUint(ErrCode, 0);
         mesg = NULL;
-        break;
     }
     blexit(mesg);
 }
index fd8b614cf49384d20f51f95c66c943ae2953165e..671ac81ecee5ed8a33f18f0a0838adc1882f7f47 100644 (file)
@@ -11,6 +11,7 @@
 #define __exit            __text_section(".exit.text")
 #define __initdata        __section(".init.data")
 #define __initconst       __section(".init.rodata")
+#define __initconstrel    __section(".init.rodata.rel")
 #define __exitdata        __used_section(".exit.data")
 #define __initsetup       __used_section(".init.setup")
 #define __init_call(lvl)  __used_section(".initcall" lvl ".init")