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

On Tuesday 11 October 2022 11:37:03 Nick Clifton wrote:
> 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.

Hello! Thank you for this information. I would suggest to extend GAS
documentation to include this kind of information into . (dot) usage as
it is not really obvious that simple form with just addition and minus
operations results in something complex with multiplication. And also
that multiplication cannot be used in dot usage.

> A clever assembler might be able to rearrange the expression, assuming that
> overflow is unimportant, but gas does not do that.

This looks like some useful feature which is not supported...

> 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

Perfect, that would be better.

> 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.

Having file name and line number would be also useful as it took me
some time to figure out where is the issue...

> 
> Cheers
>   Nick
> 

  parent reply	other threads:[~2022-10-11 10:57 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
2022-10-11 10:47       ` Richard Biener
2022-10-11 10:57       ` Pali Rohár [this message]
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=20221011105714.r5x7x4x5xsi7o7pz@pali \
    --to=pali@kernel.org \
    --cc=binutils@sourceware.org \
    --cc=gcc@gcc.gnu.org \
    --cc=nickc@redhat.com \
    --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).