Skip to content

Commit 244c369

Browse files
committed
fix(xtensa): fix confusing backtrace when PC is invalid
Before this change _invalid_pc_placeholder pointed to address of _init function from crti.o This made GDB input a bit confusing: 0x40080400 in _init () (gdb) bt #0 0x40080400 in _init () #1 0x400e519a in test_instr_fetch_prohibited () at /home/alex/git/esp-idf/tools/test_apps/system/panic/main/test_panic.c:271 #2 0x400d89a7 in app_main () at /home/alex/git/esp-idf/tools/test_apps/system/panic/main/test_app_main.c:116 #3 0x400e5f22 in main_task (args=0x0) at /home/alex/git/esp-idf/components/freertos/app_startup.c:208 #4 0x400895a8 in vPortTaskWrapper (pxCode=0x400e5eb0 <main_task>, pvParameters=0x0) at /home/alex/git/esp-idf/components/freertos/FreeRTOS-Kernel/portable/xtensa/port.c:139 After the change GDB prints output that contains a hint: _invalid_pc_placeholder () at /home/alex/git/esp-idf/components/xtensa/xtensa_vectors.S:2235 2235 UNREACHABLE_INSTRUCTION_CHECK_PREVIOUS_FRAMES (gdb) bt #0 _invalid_pc_placeholder () at /home/alex/git/esp-idf/components/xtensa/xtensa_vectors.S:2235 #1 0x400e519e in test_instr_fetch_prohibited () at /home/alex/git/esp-idf/tools/test_apps/system/panic/main/test_panic.c:271 #2 0x400d89ab in app_main () at /home/alex/git/esp-idf/tools/test_apps/system/panic/main/test_app_main.c:116 #3 0x400e5f26 in main_task (args=0x0) at /home/alex/git/esp-idf/components/freertos/app_startup.c:208 #4 0x400895a8 in vPortTaskWrapper (pxCode=0x400e5eb4 <main_task>, pvParameters=0x0) at /home/alex/git/esp-idf/components/freertos/FreeRTOS-Kernel/portable/xtensa/port.c:139
1 parent 6d945bf commit 244c369

File tree

13 files changed

+23
-57
lines changed

13 files changed

+23
-57
lines changed

components/esp_system/ld/esp32/sections.ld.in

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -212,18 +212,9 @@ SECTIONS
212212
. = 0x3C0;
213213
KEEP(*(.DoubleExceptionVector.text));
214214
. = 0x400;
215-
_invalid_pc_placeholder = ABSOLUTE(.);
216-
*(.*Vector.literal)
217-
218-
*(.UserEnter.literal);
219-
*(.UserEnter.text);
220-
. = ALIGN (16);
221-
*(.entry.literal)
222-
*(.entry.text)
223-
*(.init.literal)
224-
*(.init)
215+
KEEP(*(._invalid_pc_placeholder.text));
225216

226-
_init_end = ABSOLUTE(.);
217+
*(.*Vector.literal)
227218
} > iram0_0_seg
228219

229220
.iram0.text :

components/esp_system/ld/esp32c2/sections.ld.in

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@ SECTIONS
1919
KEEP(*(.exception_vectors_table.text));
2020
KEEP(*(.exception_vectors.text));
2121

22-
ALIGNED_SYMBOL(4, _invalid_pc_placeholder)
23-
2422
/* Code marked as running out of IRAM */
2523
_iram_text_start = ABSOLUTE(.);
2624

components/esp_system/ld/esp32c3/sections.ld.in

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -155,8 +155,6 @@ SECTIONS
155155
KEEP(*(.exception_vectors_table.text));
156156
KEEP(*(.exception_vectors.text));
157157

158-
ALIGNED_SYMBOL(4, _invalid_pc_placeholder)
159-
160158
/* Code marked as running out of IRAM */
161159
_iram_text_start = ABSOLUTE(.);
162160

components/esp_system/ld/esp32c5/sections.ld.in

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -161,8 +161,6 @@ SECTIONS
161161
KEEP(*(.exception_vectors_table.text));
162162
KEEP(*(.exception_vectors.text));
163163

164-
ALIGNED_SYMBOL(4, _invalid_pc_placeholder)
165-
166164
/* Code marked as running out of IRAM */
167165
_iram_text_start = ABSOLUTE(.);
168166

components/esp_system/ld/esp32c6/sections.ld.in

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -177,8 +177,6 @@ SECTIONS
177177
KEEP(*(.exception_vectors_table.text));
178178
KEEP(*(.exception_vectors.text));
179179

180-
ALIGNED_SYMBOL(4, _invalid_pc_placeholder)
181-
182180
/* esp_tee_config_t structure: used to share information between the TEE and REE
183181
* (e.g. interrupt handler addresses, REE flash text-rodata boundaries, etc.)
184182
* This symbol is expected by the TEE at an offset of 0x300 from the vector table start.

components/esp_system/ld/esp32c61/sections.ld.in

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@ SECTIONS
1919
KEEP(*(.exception_vectors_table.text));
2020
KEEP(*(.exception_vectors.text));
2121

22-
ALIGNED_SYMBOL(4, _invalid_pc_placeholder)
23-
2422
/* Code marked as running out of IRAM */
2523
_iram_text_start = ABSOLUTE(.);
2624

components/esp_system/ld/esp32h2/sections.ld.in

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -176,8 +176,6 @@ SECTIONS
176176
KEEP(*(.exception_vectors_table.text));
177177
KEEP(*(.exception_vectors.text));
178178

179-
ALIGNED_SYMBOL(4, _invalid_pc_placeholder)
180-
181179
/* Code marked as running out of IRAM */
182180
_iram_text_start = ABSOLUTE(.);
183181

components/esp_system/ld/esp32p4/sections.ld.in

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -186,8 +186,6 @@ SECTIONS
186186
KEEP(*(.exception_vectors_table.text));
187187
KEEP(*(.exception_vectors.text));
188188

189-
ALIGNED_SYMBOL(4, _invalid_pc_placeholder)
190-
191189
/* Code marked as running out of IRAM */
192190
_iram_text_start = ABSOLUTE(.);
193191

components/esp_system/ld/esp32s2/sections.ld.in

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -198,18 +198,9 @@ SECTIONS
198198
. = 0x3C0;
199199
KEEP(*(.DoubleExceptionVector.text));
200200
. = 0x400;
201-
_invalid_pc_placeholder = ABSOLUTE(.);
202-
*(.*Vector.literal)
203-
204-
*(.UserEnter.literal);
205-
*(.UserEnter.text);
206-
. = ALIGN (16);
207-
*(.entry.literal)
208-
*(.entry.text)
209-
*(.init.literal)
210-
*(.init)
201+
KEEP(*(._invalid_pc_placeholder.text));
211202

212-
_init_end = ABSOLUTE(.);
203+
*(.*Vector.literal)
213204
} > iram0_0_seg
214205

215206
.iram0.text :

components/esp_system/ld/esp32s3/sections.ld.in

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -181,18 +181,9 @@ SECTIONS
181181
. = 0x3C0;
182182
KEEP(*(.DoubleExceptionVector.text));
183183
. = 0x400;
184-
_invalid_pc_placeholder = ABSOLUTE(.);
185-
*(.*Vector.literal)
186-
187-
*(.UserEnter.literal);
188-
*(.UserEnter.text);
189-
. = ALIGN (16);
190-
*(.entry.literal)
191-
*(.entry.text)
192-
*(.init.literal)
193-
*(.init)
184+
KEEP(*(._invalid_pc_placeholder.text));
194185

195-
_init_end = ABSOLUTE(.);
186+
*(.*Vector.literal)
196187
} > iram0_0_seg
197188

198189
.iram0.text :

0 commit comments

Comments
 (0)