[Pdbg] [PATCH] template.S: Fix prefix mangling

Cyril Bur cyrilbur at gmail.com
Mon Dec 11 11:22:51 AEDT 2017


On Fri, 2017-12-08 at 16:55 +1030, Joel Stanley wrote:

> When I reworked Thomas' fix, I put the symbol prefix in the wrong spot.

> This resolves that bug and makes it clearer what is going on in the

> template.

>


Heh, well played Joel, this patch exposes a parallel make problem.

I can reliably reproduce on my laptop, only from a fresh checkout (`git
clean -fdx` doesn't reproduce).

diff --git a/Makefile.am b/Makefile.am
index 38a66c4..ea9d950 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -66,9 +66,9 @@ DTC_V_0       = @echo "  DTC     " $@;
 %.dtsi: %.dtsi.m4
        $(M4_V)m4 -I$(dir $<) $< > $@

-p9w-fsi.dtb.o: p9w-fsi.dts p9-fsi.dtsi
-p9r-fsi.dtb.o: p9r-fsi.dts p9-fsi.dtsi
-p9z-fsi.dtb.o: p9z-fsi.dts p9-fsi.dtsi
+p9w-fsi.dtb: p9-fsi.dtsi
+p9r-fsi.dtb: p9-fsi.dtsi
+p9z-fsi.dtb: p9-fsi.dtsi

 %.dtb: %.dts
        $(DTC_V)dtc -q -i$(dir $@) -I dts $< -O dtb > $@

Seems to fix it. I'll send that patch - maybe apply it first.

The fake backend works on my laptop and pdbg builds for and runs on
powerpc. So apart from the parallel make issue.

Reviewed-by: Cyril Bur <cyrilbur at gmail.com>

Cyril

> Fixes: 8275ca370476a3 (template.S: fix to build on architecture with non-empty __USER_LABEL_PREFIX__)

> Signed-off-by: Joel Stanley <joel at jms.id.au>

> ---

>  template.S | 20 +++++++++++---------

>  1 file changed, 11 insertions(+), 9 deletions(-)

>

> diff --git a/template.S b/template.S

> index 2b231f9de2e1..e56b7b4b0203 100644

> --- a/template.S

> +++ b/template.S

> @@ -1,14 +1,16 @@

> -#ifdef __USER_LABEL_PREFIX__

> -#define CONCAT1(a, b) CONCAT2(a, b)

> -#define CONCAT2(a, b) a ## b

> -#define SYM(x) CONCAT1 (__USER_LABEL_PREFIX__, x)

> -#else

> -#define SYM(x) x

> +// On platforms that define this macro, a symbol called "foo" in C must be

> +// named "_foo" in assembler. GCC Should always define the macro, but

> +// we add a fallback just in case

> +#ifndef __USER_LABEL_PREFIX__

> +#define __USER_LABEL_PREFIX__ ""

>  #endif

>

> -#define SYM_START(x)	CONCAT1(CONCAT1(_binary_, SYM(x)), _start)

> -#define SYM_END(x)	CONCAT1(CONCAT1(_binary_, SYM(x)), _end)

> -#define SYM_SIZE(x)	CONCAT1(CONCAT1(_binary_, SYM(x)), _size)

> +#define CONCAT1(a, b, c, d) CONCAT2(a, b, c, d)

> +#define CONCAT2(a, b, c, d) a ## b ## c ## d

> +

> +#define SYM_START(x)    CONCAT1(__USER_LABEL_PREFIX__, _binary_, x, _start)

> +#define SYM_END(x)      CONCAT1(__USER_LABEL_PREFIX__, _binary_, x, _end)

> +#define SYM_SIZE(x)     CONCAT1(__USER_LABEL_PREFIX__, _binary_, x, _size)

>

>  .section .data

>  SYM_START(SYMBOL_PREFIX):

> --

> 2.14.1

>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ozlabs.org/pipermail/pdbg/attachments/20171211/eb46e137/attachment.html>


More information about the Pdbg mailing list