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

On Tue, Oct 11, 2022 at 12:37 PM Nick Clifton <nickc@redhat.com> 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.
>
> 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.

GCC has a global input_location conveniently available when all other
bets are off.  Maybe mention "relocation" in the error message somehow?
So "expression is too complex to be resolved by a single relocation"?

Richard.

>
> Cheers
>    Nick
>

  reply	other threads:[~2022-10-11 10:47 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 [this message]
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=CAFiYyc1fzJ8LHXH6gxUmG4F8tHvmTjVcZzuVKv-sdqXBVL2pQQ@mail.gmail.com \
    --to=richard.guenther@gmail.com \
    --cc=binutils@sourceware.org \
    --cc=gcc@gcc.gnu.org \
    --cc=nickc@redhat.com \
    --cc=pali@kernel.org \
    /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).