public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
From: Nick Clifton <nickc@redhat.com>
To: "Pali Rohár" <pali@kernel.org>,
	"Richard Biener" <richard.guenther@gmail.com>
Cc: gcc@gcc.gnu.org, binutils@sourceware.org
Subject: Re: Error: attempt to get value of unresolved symbol `L0'
Date: Tue, 11 Oct 2022 11:37:03 +0100	[thread overview]
Message-ID: <d2ccafa3-e513-d0b6-9433-e2ac921d9818@redhat.com> (raw)
In-Reply-To: <20221011074309.ojqoxwsosm6v7ozc@pali>

Hi Pali, Hi Richard,

> Interesting... Another test case which is working fine:
> 
>    kernoffs:
>    .word 0x40000 - (. - 0x0)

This works because this expression can be converted into an instruction
and a relocation in the object file:

   % as t.s -o t.o
   % objdump -dr t.o
   Disassembly of section .text:

   00000000 <kernoffs>:
    0:	0003fffc 	.word	0x0003fffc
			0: R_ARM_REL32	*ABS*

Which shows that when this object file is linked the word at offset 0
inside the .text section should be converted into an absolute value of
(pc - 0x4000), where pc is the address of the word.

This instruction however:

	.word - (. - 0x80008000)

Cannot be converted since the linker would need to compute ((pc - 0x800800) * -1)
which cannot be expressed by a single relocation.  Similarly:

	.word KERNEL_OFFSET - (. - CONFIG_SYS_TEXT_BASE)

Cannot be expressed by a single value, modified by a single relocation, even
when the KERNEL_OFFSET and CONFIG_SYS_TEXT_BASE values are known at assembly
time.

A clever assembler might be able to rearrange the expression, assuming that
overflow is unimportant, but gas does not do that.  But just for reference
the following would work:

	.word KERNEL_OFFSET + CONFIG_SYS_TEXT_BASE - .


I agree however that this message:

         t.s: Error: attempt to get value of unresolved symbol `L0'

is unhelpful.  So I am going to check in a patch to change it to:

	t.s: Error: expression is too complex to be resolved

I looked into providing a file name and line number with the error
message, but this would involve reworking a lot of the assembler's
internal expression parser.

Cheers
   Nick


  reply	other threads:[~2022-10-11 10:37 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-10 17:18 Pali Rohár
2022-10-11  6:46 ` Richard Biener
2022-10-11  7:43   ` Pali Rohár
2022-10-11 10:37     ` Nick Clifton [this message]
2022-10-11 10:47       ` Richard Biener
2022-10-11 10:57       ` Pali Rohár
2022-10-11 14:33         ` Nick Clifton
2022-10-11 17:07           ` Pali Rohár
2022-10-16 10:20             ` Pali Rohár

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=d2ccafa3-e513-d0b6-9433-e2ac921d9818@redhat.com \
    --to=nickc@redhat.com \
    --cc=binutils@sourceware.org \
    --cc=gcc@gcc.gnu.org \
    --cc=pali@kernel.org \
    --cc=richard.guenther@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).