bug-binutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Bug in linker script file matching after b1eecf6f66a4a642 (prefix tree)


From: Andrew Oates
Subject: Bug in linker script file matching after b1eecf6f66a4a642 (prefix tree)
Date: Sun, 25 Jun 2023 13:20:54 -0400

Hi,

Apologies for the generic subject, I don't totally understand the
nature of the bug.

I have a basic linker script that stopped working after upgrading to
binutils 2.40.  I did a git bisect on the repository and it seems that
the breakage starts with commit
b1eecf6f66a4a642f4cb35688213e6c1c1ffdc79.

My simplified test case is as follows:

#####
$ cat test1.c
int func3(void);

int func1(void) { return func3(); }

$ cat test2.c
int func1(void);

int func2(void) { return func1(); }

$ (127) cat test3.c
int func3(void) { return 0; }

$ cat linker.ld
ENTRY (func2)

SECTIONS
{
  . = 0x1000;
  .init-text ALIGN(4) :
  {
    lib1.a(*)
  }

  . = 0xc0000000;

  .text ALIGN(4) :
  {
    *(.text)
  }
}
####

If you then run
$ ${LD} --version
GNU ld (GNU Binutils) 2.39.50.20221130
Copyright (C) 2022 Free Software Foundation, Inc.
This program is free software; you may redistribute it under the terms of
the GNU General Public License version 3 or (at your option) a later version.
This program has absolutely no warranty.
$ ${LD} -o out.bin -T linker.ld lib1.a lib2.a
$ objdump -x out.bin | grep func
c000001e g     F .text  0000000a func3
c000000f g     F .text  0000000f func1
c0000000 g     F .text  0000000f func2

you see that func1 and func2 are in .text rather than .init-text where
they should be.

Running it compiled at 50be5d11289, you get the expected result:
$ objdump -x out.bin | grep func
c0000000 g     F .text  0000000a func3
00001000 g     F .init-text     0000000f func1
0000100f g     F .init-text     0000000f func2

I don't totally understand _why_ the prefix-tree change breaks this,
but it does.  If in fact my linker script is incorrect and the commit
is not introducing a bug, what is wrong with my script?  This seems
like a pretty straightforward scenario, though.

Thanks,
Andrew



reply via email to

[Prev in Thread] Current Thread [Next in Thread]