Message ID | 20230628001356.2706-4-namit@vmware.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | .debug ignore - to squash with efi:keep efi | expand |
On Wed, Jun 28, 2023 at 12:13:51AM +0000, Nadav Amit wrote: ... > diff --git a/powerpc/Makefile.common b/powerpc/Makefile.common > index 8ce0034..c2e976e 100644 > --- a/powerpc/Makefile.common > +++ b/powerpc/Makefile.common > @@ -24,6 +24,7 @@ CFLAGS += -ffreestanding > CFLAGS += -O2 -msoft-float -mno-altivec $(mabi_no_altivec) > CFLAGS += -I $(SRCDIR)/lib -I $(SRCDIR)/lib/libfdt -I lib > CFLAGS += -Wa,-mregnames > +CFLAGS += -DCONFIG_RELOC > I dropped this change. powerpc doesn't define _text and _etext. I'll leave it to the ppc people to decide if they want this and want to add _text and _etext to get it. Thanks, drew
> On Jul 1, 2023, at 4:34 AM, Andrew Jones <andrew.jones@linux.dev> wrote: > > !! External Email > > On Wed, Jun 28, 2023 at 12:13:51AM +0000, Nadav Amit wrote: > ... >> diff --git a/powerpc/Makefile.common b/powerpc/Makefile.common >> index 8ce0034..c2e976e 100644 >> --- a/powerpc/Makefile.common >> +++ b/powerpc/Makefile.common >> @@ -24,6 +24,7 @@ CFLAGS += -ffreestanding >> CFLAGS += -O2 -msoft-float -mno-altivec $(mabi_no_altivec) >> CFLAGS += -I $(SRCDIR)/lib -I $(SRCDIR)/lib/libfdt -I lib >> CFLAGS += -Wa,-mregnames >> +CFLAGS += -DCONFIG_RELOC >> > > I dropped this change. powerpc doesn't define _text and _etext. > I'll leave it to the ppc people to decide if they want this and > want to add _text and _etext to get it. Thanks for taking care of it. Sorry for not noticing. I am always not inclined to change arch’s that I don’t use.
diff --git a/Makefile b/Makefile index 307bc29..ae79059 100644 --- a/Makefile +++ b/Makefile @@ -40,7 +40,7 @@ OBJDIRS += $(LIBFDT_objdir) # EFI App ifeq ($(CONFIG_EFI),y) -EFI_CFLAGS := -DCONFIG_EFI +EFI_CFLAGS := -DCONFIG_EFI -DCONFIG_RELOC # The following CFLAGS and LDFLAGS come from: # - GNU-EFI/Makefile.defaults # - GNU-EFI/apps/Makefile diff --git a/arm/Makefile.arm64 b/arm/Makefile.arm64 index eada7f9..85b3348 100644 --- a/arm/Makefile.arm64 +++ b/arm/Makefile.arm64 @@ -12,6 +12,7 @@ CFLAGS += -mstrict-align mno_outline_atomics := $(call cc-option, -mno-outline-atomics, "") CFLAGS += $(mno_outline_atomics) +CFLAGS += -DCONFIG_RELOC define arch_elf_check = $(if $(shell ! $(READELF) -rW $(1) >&/dev/null && echo "nok"), diff --git a/lib/stack.c b/lib/stack.c index bdb23fd..dd6bfa8 100644 --- a/lib/stack.c +++ b/lib/stack.c @@ -6,13 +6,38 @@ */ #include <libcflat.h> +#include <stdbool.h> #include <stack.h> #define MAX_DEPTH 20 +#ifdef CONFIG_RELOC +extern char _text, _etext; + +static bool base_address(const void *rebased_addr, unsigned long *addr) +{ + unsigned long ra = (unsigned long)rebased_addr; + unsigned long start = (unsigned long)&_text; + unsigned long end = (unsigned long)&_etext; + + if (ra < start || ra >= end) + return false; + + *addr = ra - start; + return true; +} +#else +static bool base_address(const void *rebased_addr, unsigned long *addr) +{ + *addr = (unsigned long)rebased_addr; + return true; +} +#endif + static void print_stack(const void **return_addrs, int depth, bool top_is_return_address) { + unsigned long addr; int i = 0; printf("\tSTACK:"); @@ -20,12 +45,14 @@ static void print_stack(const void **return_addrs, int depth, /* @addr indicates a non-return address, as expected by the stack * pretty printer script. */ if (depth > 0 && !top_is_return_address) { - printf(" @%lx", (unsigned long) return_addrs[0]); + if (base_address(return_addrs[0], &addr)) + printf(" @%lx", addr); i++; } for (; i < depth; i++) { - printf(" %lx", (unsigned long) return_addrs[i]); + if (base_address(return_addrs[i], &addr)) + printf(" %lx", addr); } printf("\n"); } diff --git a/powerpc/Makefile.common b/powerpc/Makefile.common index 8ce0034..c2e976e 100644 --- a/powerpc/Makefile.common +++ b/powerpc/Makefile.common @@ -24,6 +24,7 @@ CFLAGS += -ffreestanding CFLAGS += -O2 -msoft-float -mno-altivec $(mabi_no_altivec) CFLAGS += -I $(SRCDIR)/lib -I $(SRCDIR)/lib/libfdt -I lib CFLAGS += -Wa,-mregnames +CFLAGS += -DCONFIG_RELOC # We want to keep intermediate files .PRECIOUS: %.o