Skip to content

Commit 4890aaf

Browse files
Replace ASM block w/C marco for PSTR
GAS doesn't support the C language idiom of catenating two strings together with quotes (i.e. "x" "y" === "xy"). Specify the section attribute fully in the section attribute, instead, to allow this. Fixes esp8266#6575 and probably esp8266#6574
1 parent 1aeea12 commit 4890aaf

File tree

1 file changed

+2
-6
lines changed
  • tools/sdk/libc/xtensa-lx106-elf/include/sys

1 file changed

+2
-6
lines changed

tools/sdk/libc/xtensa-lx106-elf/include/sys/pgmspace.h

+2-6
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ extern "C" {
2323
// Ref: https://gcc.gnu.org/onlinedocs/gcc-3.2/gcc/Variable-Attributes.html
2424
// Place each progmem object into its own named section, avoiding conflicts
2525
#define PROGMEM __attribute__((section( "\".irom.text." __FILE__ "." __STRINGIZE(__LINE__) "." __STRINGIZE(__COUNTER__) "\"")))
26-
#define PROGMEM_PSTR "\".irom0.pstr." __FILE__ "." __STRINGIZE(__LINE__) "." __STRINGIZE(__COUNTER__) "\""
2726
#endif
2827
#ifndef PGM_P
2928
#define PGM_P const char *
@@ -36,11 +35,8 @@ extern "C" {
3635
// 1.5 bytes/string, but in return memcpy_P and strcpy_P will work 4~8x faster
3736
#ifndef PSTR
3837
// Adapted from AVR-specific code at https://forum.arduino.cc/index.php?topic=194603.0
39-
#define PSTR(str) (__extension__({ \
40-
PGM_P ptr; \
41-
asm volatile ( ".pushsection " PROGMEM_PSTR ", \"aSM\", @progbits, 1 \n .align 4 \n 0: .string " __STRINGIZE(str) "\n .popsection \n" ); \
42-
asm volatile ( "movi %0, 0b" : "=r" (ptr) ); \
43-
ptr; }))
38+
// Uses C attribute section instead of ASM block to allow for C language string concatenation ("x" "y" === "xy")
39+
#define PSTR(s) (__extension__({static const char __c[] __attribute__((__aligned__(4))) __attribute__((section( "\".irom0.pstr." __FILE__ "." __STRINGIZE(__LINE__) "." __STRINGIZE(__COUNTER__) "\", \"aSM\", @progbits, 1 #"))) = (s); &__c[0];}))
4440
#endif
4541

4642
// Flash memory must be read using 32 bit aligned addresses else a processor

0 commit comments

Comments
 (0)