From 42b47dae498aa7b849b9c9a165b22146de1934a1 Mon Sep 17 00:00:00 2001 From: Andrew Stubbs Date: Fri, 17 Jul 2020 11:45:34 +0100 Subject: [PATCH] amdgcn: Fix elf.h build issue Allow building on systems with elf.h that includes AMDGPU definitions, partially or completely. gcc/ChangeLog: * config/gcn/mkoffload.c (EM_AMDGPU): Undefine before defining. (ELFOSABI_AMDGPU_HSA): Likewise. (ELFABIVERSION_AMDGPU_HSA): Likewise. (EF_AMDGPU_MACH_AMDGCN_GFX803): Likewise. (EF_AMDGPU_MACH_AMDGCN_GFX900): Likewise. (EF_AMDGPU_MACH_AMDGCN_GFX906): Likewise. (reserved): Delete. --- gcc/config/gcn/mkoffload.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/gcc/config/gcn/mkoffload.c b/gcc/config/gcn/mkoffload.c index 553f25e70df..808ce53176c 100644 --- a/gcc/config/gcn/mkoffload.c +++ b/gcc/config/gcn/mkoffload.c @@ -36,17 +36,23 @@ #include "simple-object.h" #include "elf.h" -/* These probably won't be in elf.h for a while. */ -#ifndef EM_AMDGPU +/* These probably won't (all) be in elf.h for a while. */ +#undef EM_AMDGPU #define EM_AMDGPU 0xe0; +#undef ELFOSABI_AMDGPU_HSA #define ELFOSABI_AMDGPU_HSA 64 +#undef ELFABIVERSION_AMDGPU_HSA #define ELFABIVERSION_AMDGPU_HSA 1 +#undef EF_AMDGPU_MACH_AMDGCN_GFX803 #define EF_AMDGPU_MACH_AMDGCN_GFX803 0x2a +#undef EF_AMDGPU_MACH_AMDGCN_GFX900 #define EF_AMDGPU_MACH_AMDGCN_GFX900 0x2c +#undef EF_AMDGPU_MACH_AMDGCN_GFX906 #define EF_AMDGPU_MACH_AMDGCN_GFX906 0x2f +#ifndef R_AMDGPU_NONE #define R_AMDGPU_NONE 0 #define R_AMDGPU_ABS32_LO 1 /* (S + A) & 0xFFFFFFFF */ #define R_AMDGPU_ABS32_HI 2 /* (S + A) >> 32 */ @@ -59,7 +65,6 @@ #define R_AMDGPU_GOTPCREL32_HI 9 /* (G + GOT + A - P) >> 32 */ #define R_AMDGPU_REL32_LO 10 /* (S + A - P) & 0xFFFFFFFF */ #define R_AMDGPU_REL32_HI 11 /* (S + A - P) >> 32 */ -#define reserved 12 #define R_AMDGPU_RELATIVE64 13 /* B + A */ #endif -- 2.30.2