[PATCH] RISC-V: fix linker message when relaxation deletes bytes

Clément Chigot chigot@adacore.com
Thu Oct 20 07:20:23 GMT 2022


Hi Jeff

On Wed, Oct 19, 2022 at 7:38 PM Jeff Law <jeffreyalaw@gmail.com> wrote:
>
>
> On 10/17/22 02:32, Clément Chigot wrote:
> >
> > Yeah, that's what was already done in the Risc-V function:
> > riscv_relax_delete_bytes.
> > However, local and global symbols aren't enough for linker warnings
> > and errors. These ones are using the "outsymbols" BFD field which IIUC
> > is reading the object files directly and thus cannot know about the
> > deleted bytes.
>
> But if you're getting the outsymbols for the output bfd, then they
> should have the right address.  If they don't, then the symbol table in
> the output file is going to be wrong.  And changing the local/global
> symbols when relaxing should directly influence the outsymbols for the
> output bfd.

For Risc-V, it seems that outsymbols aren't needed for the output file
symbol table. I've tried with different programs, bfd_get_outsymbols
seems to be reached only when an error has to be displayed.

> > So I guess H8 might have the same kind of errors. Are ld-undefined
> > tests succeeding ?
>
> Which test specifically?  None are failing, but some are
> UNTESTED/UNSUPPORTED:
>
>
> UNSUPPORTED: -shared --entry foo archive
> UNSUPPORTED: -shared --entry foo -u foo archive
> UNTESTED: undefined
> UNTESTED: undefined function
> UNTESTED: undefined line
> UNSUPPORTED: undefined symbols in shared lib
> UNSUPPORTED: weak undefined function symbols in shared lib
>
>
> Do I need to turn on relaxing by default to see this issue (unlike
> riscv, h8 does not enable relaxing by default).

Hum, I guess they are probably disabled because you haven't a compiler
available for H8 or at least it's not properly set up for the
testsuites.
The way I'm enabling them is by passing a "board" to DejaGNU (see
[1]). This board will have the correct CFLAGS and LDFLAGS.
  | set_board_info ldflags  "${CFLAGS}"
  | set_board_info ldflags  "${LDFLAGS}"
  | set_currtarget_info ldflags  "${CFLAGS}"
  | set_currtarget_info ldflags  "${LDFLAGS}"

Note that I stated in a recent patch improving the support for
LDFLAGS, I'm not sure why both set_board and set_currtarget are
needed. But I do need both to make it work.

[1] https://www.gnu.org/software/dejagnu/manual/Adding-a-new-board.html
[2] https://sourceware.org/pipermail/binutils/2022-October/123314.html


More information about the Binutils mailing list