# Cannot compile Xtensa port assembly with --text-section-literals

**URL:** <https://forums.freertos.org/t/cannot-compile-xtensa-port-assembly-with-text-section-literals/14838>\
**Category:** Kernel\
**Created:** [April 11, 2022, 2:25pm UTC](https://forums.freertos.org/t/cannot-compile-xtensa-port-assembly-with-text-section-literals/14838 "2022-04-11T14:25:12Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![ChiTran](https://avatars.discourse-cdn.com/v4/letter/c/7ab992/32.png) [@ChiTran](https://forums.freertos.org/u/ChiTran)\
**Post date:** [April 11, 2022, 2:25pm UTC](https://forums.freertos.org/t/cannot-compile-xtensa-port-assembly-with-text-section-literals/14838/1 "2022-04-11T14:25:13Z")

</div>

Hi,

I could not compile the assembly source of Xtensa port with --text-section-literals. I read somewhere they say that I have to add .literal\_position directive.  
I fixed it in my own work. Could you please support these changes in the official repository?

Thanks,  
Chi Tran

---

<div class="post-metadata">

**Author:** ![archigup](https://d3iykfbgfh8zhg.cloudfront.net/user_avatar/forums.freertos.org/archigup/32/1418_2.png) [@archigup](https://forums.freertos.org/u/archigup)\
**Post date:** [April 11, 2022, 4:24pm UTC](https://forums.freertos.org/t/cannot-compile-xtensa-port-assembly-with-text-section-literals/14838/2 "2022-04-11T16:24:41Z")

</div>

Hi, could you point out which repository you are using?

Additionally, do you have a patch with the changes you made to support this flag?

Thanks

---

<div class="post-metadata">

**Author:** ![ChiTran](https://avatars.discourse-cdn.com/v4/letter/c/7ab992/32.png) [@ChiTran](https://forums.freertos.org/u/ChiTran)\
**Post date:** [April 11, 2022, 5:29pm UTC](https://forums.freertos.org/t/cannot-compile-xtensa-port-assembly-with-text-section-literals/14838/3 "2022-04-11T17:29:32Z")

</div>

Hi Archit,

I’m using the public github repository, branch main.  
`https://github.com/FreeRTOS/FreeRTOS-Kernel.git`

My patch is following:

```auto
diff --git a/portable/ThirdParty/XCC/Xtensa/xtensa_context.S b/portable/ThirdParty/XCC/Xtensa/xtensa_context.S
index 55ce8e0..a6545b9 100644
--- a/portable/ThirdParty/XCC/Xtensa/xtensa_context.S
+++ b/portable/ThirdParty/XCC/Xtensa/xtensa_context.S
@@ -62,6 +62,7 @@ NOERROR: .error "C preprocessor needed for this file: make sure its filename\
 #endif
 
     .text
+ .literal_position
 
 / *******************************************************************************
 
diff --git a/portable/ThirdParty/XCC/Xtensa/xtensa_vectors.S b/portable/ThirdParty/XCC/Xtensa/xtensa_vectors.S
index bf5916c..6cb8f37 100644
--- a/portable/ThirdParty/XCC/Xtensa/xtensa_vectors.S
+++ b/portable/ThirdParty/XCC/Xtensa/xtensa_vectors.S
@@ -306,6 +306,7 @@
     .global _xt_panic
     .type _xt_panic,@function
     .align 4
+ .literal_position
 
 _xt_panic:
     #ifdef XT_SIMULATOR
@@ -386,6 +387,7 @@ Debug Exception.
     .section .DebugExceptionVector.text, "ax"
     .global _DebugExceptionVector
     .align 4
+ .literal_position
 
 _DebugExceptionVector:
 
@@ -424,6 +426,7 @@ Double exceptions are not a normal occurrence. They indicate a bug of some kind.
     .section .DoubleExceptionVector.text, "ax"
     .global _DoubleExceptionVector
     .align 4
+ .literal_position
 
 _DoubleExceptionVector:
 
@@ -447,6 +450,7 @@ Kernel Exception (including Level 1 Interrupt from kernel mode).
     .section .KernelExceptionVector.text, "ax"
     .global _KernelExceptionVector
     .align 4
+ .literal_position
 
 _KernelExceptionVector:
 
@@ -478,6 +482,7 @@ User Exception (including Level 1 Interrupt from user mode).
     .global _UserExceptionVector
     .type _UserExceptionVector,@function
     .align 4
+ .literal_position
 
 _UserExceptionVector:
 
@@ -1036,6 +1041,8 @@ _xt_lowint1:
     .global _Level2Vector
     .type _Level2Vector,@function
     .align 4
+ .literal_position
+
 _Level2Vector:
     wsr a0, EXCSAVE_2 /* preserve a0 */
     call0 _xt_medint2 /* load interrupt handler */
@@ -1107,6 +1114,8 @@ _xt_medint2_exit:
     .global _Level3Vector
     .type _Level3Vector,@function
     .align 4
+ .literal_position
+
 _Level3Vector:
     wsr a0, EXCSAVE_3 /* preserve a0 */
     call0 _xt_medint3 /* load interrupt handler */
@@ -1506,6 +1515,8 @@ _xt_highint3:
     .global _Level4Vector
     .type _Level4Vector,@function
     .align 4
+ .literal_position
+
 _Level4Vector:
     wsr a0, EXCSAVE_4 /* preserve a0 */
     call0 _xt_highint4 /* load interrupt handler */
@@ -1546,6 +1557,8 @@ _xt_highint4:
     .global _Level5Vector
     .type _Level5Vector,@function
     .align 4
+ .literal_position
+
 _Level5Vector:
     wsr a0, EXCSAVE_5 /* preserve a0 */
     call0 _xt_highint5 /* load interrupt handler */
@@ -1626,6 +1639,8 @@ _xt_highint6:
     .global _NMIExceptionVector
     .type _NMIExceptionVector,@function
     .align 4
+ .literal_position
+
 _NMIExceptionVector:
     wsr a0, EXCSAVE + XCHAL_NMILEVEL _ /* preserve a0 */
     call0 _xt_nmi /* load interrupt handler */

```

Chi

---

<div class="post-metadata">

**Author:** ![archigup](https://d3iykfbgfh8zhg.cloudfront.net/user_avatar/forums.freertos.org/archigup/32/1418_2.png) [@archigup](https://forums.freertos.org/u/archigup)\
**Post date:** [April 11, 2022, 10:02pm UTC](https://forums.freertos.org/t/cannot-compile-xtensa-port-assembly-with-text-section-literals/14838/4 "2022-04-11T22:02:22Z")

</div>

Hi, I put the patch in a PR here: [Enable use of --text-section-literals in Xtensa port by archigup · Pull Request #485 · FreeRTOS/FreeRTOS-Kernel · GitHub](https://github.com/FreeRTOS/FreeRTOS-Kernel/pull/485)

---

<div class="post-metadata">

**Author:** ![ChiTran](https://avatars.discourse-cdn.com/v4/letter/c/7ab992/32.png) [@ChiTran](https://forums.freertos.org/u/ChiTran)\
**Post date:** [April 11, 2022, 10:31pm UTC](https://forums.freertos.org/t/cannot-compile-xtensa-port-assembly-with-text-section-literals/14838/5 "2022-04-11T22:31:52Z")

</div>

Thank you so much.  
Chi
