diff options
author | Joel Stanley <joel@jms.id.au> | 2017-12-08 16:55:55 +1030 |
---|---|---|
committer | Alistair Popple <alistair@popple.id.au> | 2017-12-11 17:33:15 +1100 |
commit | 139ba071c222a5b0c20075f7c2265029ddd59449 (patch) | |
tree | aa2d91fa3ba955f28d4b9b961f112aae1e6f0756 | |
parent | 404cf344dc13b11b333f060e8c0ca7e552f11d81 (diff) | |
download | pdbg-139ba071c222a5b0c20075f7c2265029ddd59449.tar.gz pdbg-139ba071c222a5b0c20075f7c2265029ddd59449.zip |
template.S: Fix prefix mangling
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.
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>
-rw-r--r-- | template.S | 20 |
1 files changed, 11 insertions, 9 deletions
@@ -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): |