Skip to contentSkip to conversation

Nokia RX-51: Fix compilation with non-zero CONFIG_SYS_TEXT_BASE

PATCH In review Pali Rohár 2 participants 7 messages Oct 9, 2022 – Oct 18, 2022 Arm/actions semi architecture

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Nokia RX-51: Fix compilation with non-zero CONFIG_SYS_TEXT_BASE

For some unknown reason GNU assembler version 2.31.1 (arm-linux-gnueabi-as from Debian Buster) cannot compile following code from located in file board/nokia/rx51/lowlevel_init.S:

kernoffs:
.word KERNEL_OFFSET - (. - CONFIG_SYS_TEXT_BASE)

when CONFIG_SYS_TEXT_BASE is set to 0x80008000. It throws strange compile error which is even without line number:

AS board/nokia/rx51/lowlevel_init.o
{standard input}: Assembler messages:
{standard input}: Error: attempt to get value of unresolved symbol `L0' make[2]: *** [scripts/Makefile.build:293: board/nokia/rx51/lowlevel_init.o] Error 1

I have no idea about this error and my experiments showed that ARM GNU assembler is happy with negation of that number. So changing code to:

kernoffs:
.word . - CONFIG_SYS_TEXT_BASE - KERNEL_OFFSET

and then replacing mathematical addition by substraction of "kernoffs" value (so calculation of address does not change) compiles assembler file without any error now.

There should be not any functional change.

---
Btw, is somebody understanding that compile error message? Is there (or was there) some real issue in the code, so assembler refuse to compile it? Or have I triggered bug in GNU assembler?

---
 board/nokia/rx51/lowlevel_init.S | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
board/nokia/rx51/lowlevel_init.S +2 -2
index 1cf8f8d8b2f7..4b66e0a86140 100644
@@ -7,7 +7,7 @@
 #include <config.h>
 
 kernoffs:		/* offset of kernel image from this address */
-	.word KERNEL_OFFSET - (. - CONFIG_SYS_TEXT_BASE)
+	.word . - CONFIG_SYS_TEXT_BASE - KERNEL_OFFSET
 
 kernaddr:		/* address of kernel after copying */
 	.word KERNEL_ADDRESS
@@ -49,7 +49,7 @@ save_boot_params:
 	/* r0 - start of kernel before */
 	adr	r0, kernoffs	/* r0 - current address of kernoffs section */
 	ldr	r1, kernoffs	/* r1 - offset of kernel image from kernoffs section */
-	add	r0, r0, r1
+	sub	r0, r0, r1
 
 	/* r3 - start of kernel after */
 	ldr	r3, kernaddr
Signature · 1 line
2.20.1
#1 lore raw
Quoted 25 lines · Pali Rohár

For some unknown reason GNU assembler version 2.31.1 (arm-linux-gnueabi-as from Debian Buster) cannot compile following code from located in file board/nokia/rx51/lowlevel_init.S:

kernoffs:
.word KERNEL_OFFSET - (. - CONFIG_SYS_TEXT_BASE)

when CONFIG_SYS_TEXT_BASE is set to 0x80008000. It throws strange compile error which is even without line number:

AS board/nokia/rx51/lowlevel_init.o
{standard input}: Assembler messages:
{standard input}: Error: attempt to get value of unresolved symbol `L0' make[2]: *** [scripts/Makefile.build:293: board/nokia/rx51/lowlevel_init.o] Error 1

I have no idea about this error and my experiments showed that ARM GNU assembler is happy with negation of that number. So changing code to:

kernoffs:
.word . - CONFIG_SYS_TEXT_BASE - KERNEL_OFFSET

and then replacing mathematical addition by substraction of "kernoffs" value (so calculation of address does not change) compiles assembler file without any error now.

Quoted 7 lines

There should be not any functional change.

---
Btw, is somebody understanding that compile error message? Is there (or was there) some real issue in the code, so assembler refuse to compile it? Or have I triggered bug in GNU assembler?

I would suggest filing a bug with upstream GNU assembler and seeing what they say.

Signature · 1 line
Tom
#2 lore raw
Quoted 29 lines · On Monday 10 October 2022 09:54:02 Tom Rini wrote:
Quoted 27 lines · Pali Rohár

For some unknown reason GNU assembler version 2.31.1 (arm-linux-gnueabi-as from Debian Buster) cannot compile following code from located in file board/nokia/rx51/lowlevel_init.S:

kernoffs:
.word KERNEL_OFFSET - (. - CONFIG_SYS_TEXT_BASE)

when CONFIG_SYS_TEXT_BASE is set to 0x80008000. It throws strange compile error which is even without line number:

AS board/nokia/rx51/lowlevel_init.o
{standard input}: Assembler messages:
{standard input}: Error: attempt to get value of unresolved symbol `L0' make[2]: *** [scripts/Makefile.build:293: board/nokia/rx51/lowlevel_init.o] Error 1

I have no idea about this error and my experiments showed that ARM GNU assembler is happy with negation of that number. So changing code to:

kernoffs:
.word . - CONFIG_SYS_TEXT_BASE - KERNEL_OFFSET

and then replacing mathematical addition by substraction of "kernoffs" value (so calculation of address does not change) compiles assembler file without any error now.

There should be not any functional change.

Quoted 8 lines
Quoted 5 lines

---
Btw, is somebody understanding that compile error message? Is there (or was there) some real issue in the code, so assembler refuse to compile it? Or have I triggered bug in GNU assembler?

I would suggest filing a bug with upstream GNU assembler and seeing what they say.

And it is really a bug? Is not that issue in current code?

#3 lore raw
Quoted 36 lines · Pali Rohár
Quoted 35 lines · On Monday 10 October 2022 09:54:02 Tom Rini wrote:
Quoted 32 lines · Pali Rohár

For some unknown reason GNU assembler version 2.31.1 (arm-linux-gnueabi-as from Debian Buster) cannot compile following code from located in file board/nokia/rx51/lowlevel_init.S:

kernoffs:
.word KERNEL_OFFSET - (. - CONFIG_SYS_TEXT_BASE)

when CONFIG_SYS_TEXT_BASE is set to 0x80008000. It throws strange compile error which is even without line number:

AS board/nokia/rx51/lowlevel_init.o
{standard input}: Assembler messages:
{standard input}: Error: attempt to get value of unresolved symbol `L0' make[2]: *** [scripts/Makefile.build:293: board/nokia/rx51/lowlevel_init.o] Error 1

I have no idea about this error and my experiments showed that ARM GNU assembler is happy with negation of that number. So changing code to:

kernoffs:
.word . - CONFIG_SYS_TEXT_BASE - KERNEL_OFFSET

and then replacing mathematical addition by substraction of "kernoffs" value (so calculation of address does not change) compiles assembler file without any error now.

There should be not any functional change.

---
Btw, is somebody understanding that compile error message? Is there (or was there) some real issue in the code, so assembler refuse to compile it? Or have I triggered bug in GNU assembler?

Quoted 4 lines
Quoted 2 lines

I would suggest filing a bug with upstream GNU assembler and seeing what they say.

And it is really a bug? Is not that issue in current code?

I think filing an issue is the best way to find out if we were relying on something undocumented that worked or if it's a regression in the tooling.

Signature · 1 line
Tom
#4 lore raw
Quoted 37 lines · On Monday 10 October 2022 12:21:56 Tom Rini wrote:
Quoted 36 lines · Pali Rohár
Quoted 35 lines · On Monday 10 October 2022 09:54:02 Tom Rini wrote:
Quoted 32 lines · Pali Rohár

For some unknown reason GNU assembler version 2.31.1 (arm-linux-gnueabi-as from Debian Buster) cannot compile following code from located in file board/nokia/rx51/lowlevel_init.S:

kernoffs:
.word KERNEL_OFFSET - (. - CONFIG_SYS_TEXT_BASE)

when CONFIG_SYS_TEXT_BASE is set to 0x80008000. It throws strange compile error which is even without line number:

AS board/nokia/rx51/lowlevel_init.o
{standard input}: Assembler messages:
{standard input}: Error: attempt to get value of unresolved symbol `L0' make[2]: *** [scripts/Makefile.build:293: board/nokia/rx51/lowlevel_init.o] Error 1

I have no idea about this error and my experiments showed that ARM GNU assembler is happy with negation of that number. So changing code to:

kernoffs:
.word . - CONFIG_SYS_TEXT_BASE - KERNEL_OFFSET

and then replacing mathematical addition by substraction of "kernoffs" value (so calculation of address does not change) compiles assembler file without any error now.

There should be not any functional change.

---
Btw, is somebody understanding that compile error message? Is there (or was there) some real issue in the code, so assembler refuse to compile it? Or have I triggered bug in GNU assembler?

Quoted 11 lines
Quoted 4 lines
Quoted 2 lines

I would suggest filing a bug with upstream GNU assembler and seeing what they say.

And it is really a bug? Is not that issue in current code?

I think filing an issue is the best way to find out if we were relying on something undocumented that worked or if it's a regression in the tooling.

Signature · 1 line
Tom

Ok, I sent email to binutils and gcc mailing list about this issue:
https://sourceware.org/pipermail/binutils/2022-October/123472.html
https://gcc.gnu.org/pipermail/gcc/2022-October/239588.html

Reviewed-by on v1 1/1
#5 lore raw
In reply to Pali Rohár
Quoted 21 lines · Pali Rohár

For some unknown reason GNU assembler version 2.31.1 (arm-linux-gnueabi-as from Debian Buster) cannot compile following code from located in file board/nokia/rx51/lowlevel_init.S:

kernoffs:
.word KERNEL_OFFSET - (. - CONFIG_SYS_TEXT_BASE)

when CONFIG_SYS_TEXT_BASE is set to 0x80008000. It throws strange compile error which is even without line number:

AS board/nokia/rx51/lowlevel_init.o
{standard input}: Assembler messages:
{standard input}: Error: attempt to get value of unresolved symbol `L0' make[2]: *** [scripts/Makefile.build:293: board/nokia/rx51/lowlevel_init.o] Error 1

I have no idea about this error and my experiments showed that ARM GNU assembler is happy with negation of that number. So changing code to:

kernoffs:
.word . - CONFIG_SYS_TEXT_BASE - KERNEL_OFFSET

Quoted 7 lines

and then replacing mathematical addition by substraction of "kernoffs" value (so calculation of address does not change) compiles assembler file without any error now.

There should be not any functional change.

Thanks for following up with upstream here. I see they didn't answer your final question, but my read of the series is that what you're doing here should always work.

Signature · 1 line
Tom
#6 lore raw
In reply to Pali Rohár
Quoted 21 lines · Pali Rohár

For some unknown reason GNU assembler version 2.31.1 (arm-linux-gnueabi-as from Debian Buster) cannot compile following code from located in file board/nokia/rx51/lowlevel_init.S:

kernoffs:
.word KERNEL_OFFSET - (. - CONFIG_SYS_TEXT_BASE)

when CONFIG_SYS_TEXT_BASE is set to 0x80008000. It throws strange compile error which is even without line number:

AS board/nokia/rx51/lowlevel_init.o
{standard input}: Assembler messages:
{standard input}: Error: attempt to get value of unresolved symbol `L0' make[2]: *** [scripts/Makefile.build:293: board/nokia/rx51/lowlevel_init.o] Error 1

I have no idea about this error and my experiments showed that ARM GNU assembler is happy with negation of that number. So changing code to:

kernoffs:
.word . - CONFIG_SYS_TEXT_BASE - KERNEL_OFFSET

Quoted 8 lines

and then replacing mathematical addition by substraction of "kernoffs" value (so calculation of address does not change) compiles assembler file without any error now.

There should be not any functional change.

Applied to u-boot/master, thanks!

Signature · 1 line
Tom