Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ld-elf2flt: behave properly when called with a name different from TA… #8

Merged
merged 1 commit into from Dec 29, 2019

Conversation

tpetazzoni
Copy link
Contributor

…RGET_ALIAS

ld-elf2flt currently handles two cases:

1 It is called as the wrapper for <TARGET_ALIAS>-ld, generally
installed in the bin/ directory of a toolchain.

2 It is called as the wrapper for "ld", generally installed in the
TARGET_ALIAS/bin/ directory of a toolchain.

Unfortunately, if for some reason it gets called using a FOOBAR-ld
name that is different from <TARGET_ALIAS>-ld, it assumes it is in
case (2), while it really is in case (1). Due to this, the path
mangling logic doesn't work, and it doesn't find ld.real.

This happens for example when the binary program in bin/ is named
arm-buildroot-uclinux-uclibcgnueabi-ld, but also has a simpler symlink
named arm-linux-ld. In this case,
arm-buildroot-uclinux-uclibcgnueabi-ld is recognized by ld-elf2flt as
containing TARGET_ALIAS, and therefore the proper logic to find
ld.real is applied. However, when arm-linux-ld is used, ld-elf2flt
doesn't find TARGET_ALIAS, and therefore assumes we're being called as
TARGET_ALIAS/bin/ld.. and searches for a program called ld.real in
bin/, which doesn't exist.

See:

$ ./output/host/bin/arm-buildroot-uclinux-uclibcgnueabi-ld
/home/thomas/buildroot/buildroot/output/host/bin/../arm-buildroot-uclinux-uclibcgnueabi/bin/ld.real: no input files

$ ./output/host/bin/arm-linux-ld
arm-linux-ld (ld-elf2flt): error trying to exec '/home/thomas/buildroot/buildroot/output/host/bin/ld.real': execvp: No such file or directory

$ ./output/host/arm-buildroot-uclinux-uclibcgnueabi/bin/ld
/home/thomas/buildroot/buildroot/output/host/arm-buildroot-uclinux-uclibcgnueabi/bin/ld.real: no input files

This commit fixes that by inverting the logic: if we're being called
as just "ld", then we assume it's the program in
TARGET_ALIAS/bin/. Otherwise, we're called through some variant of
TARGET-ld.

Signed-off-by: Thomas Petazzoni thomas.petazzoni@free-electrons.com

…RGET_ALIAS

ld-elf2flt currently handles two cases:

 1 It is called as the wrapper for <TARGET_ALIAS>-ld, generally
   installed in the bin/ directory of a toolchain.

 2 It is called as the wrapper for "ld", generally installed in the
   TARGET_ALIAS/bin/ directory of a toolchain.

Unfortunately, if for some reason it gets called using a FOOBAR-ld
name that is different from <TARGET_ALIAS>-ld, it assumes it is in
case (2), while it really is in case (1). Due to this, the path
mangling logic doesn't work, and it doesn't find ld.real.

This happens for example when the binary program in bin/ is named
arm-buildroot-uclinux-uclibcgnueabi-ld, but also has a simpler symlink
named arm-linux-ld. In this case,
arm-buildroot-uclinux-uclibcgnueabi-ld is recognized by ld-elf2flt as
containing TARGET_ALIAS, and therefore the proper logic to find
ld.real is applied. However, when arm-linux-ld is used, ld-elf2flt
doesn't find TARGET_ALIAS, and therefore assumes we're being called as
TARGET_ALIAS/bin/ld.. and searches for a program called ld.real in
bin/, which doesn't exist.

See:

$ ./output/host/bin/arm-buildroot-uclinux-uclibcgnueabi-ld
/home/thomas/buildroot/buildroot/output/host/bin/../arm-buildroot-uclinux-uclibcgnueabi/bin/ld.real: no input files

$ ./output/host/bin/arm-linux-ld
arm-linux-ld (ld-elf2flt): error trying to exec '/home/thomas/buildroot/buildroot/output/host/bin/ld.real': execvp: No such file or directory

$ ./output/host/arm-buildroot-uclinux-uclibcgnueabi/bin/ld
/home/thomas/buildroot/buildroot/output/host/arm-buildroot-uclinux-uclibcgnueabi/bin/ld.real: no input files

This commit fixes that by inverting the logic: if we're being called
as just "ld", then we assume it's the program in
TARGET_ALIAS/bin/. Otherwise, we're called through some variant of
TARGET-ld.

Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
RomainNaour added a commit to RomainNaour/buildroot that referenced this pull request Mar 10, 2019
Binutils added bfd_stdint.h to bfd.h [1], so elf2flt must create a
symlink for this header.

Bump the elf2flt version that include the upstream fix [2].

Keep our local patch 0001-ld-elf2flt-behave-properly-when-called-with-a-name-d.patch
that was not integrated with the recent project activity [3].

Fixes:
[armv7m-uclibc]
https://gitlab.com/kubu93/toolchains-builder/-/jobs/148356410

[m68k-coldfire-uclibc]
https://gitlab.com/kubu93/toolchains-builder/-/jobs/148356412

[1] https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;a=commitdiff;h=2d5d5a8f0a8b5a03454bf168b7fa7024bb1ebbd8
[2] uclinux-dev/elf2flt@429521f
[3] uclinux-dev/elf2flt#8

Signed-off-by: Romain Naour <romain.naour@gmail.com>
---
v2: bump the version instead of adding a new local patch (Arnout).
@tpetazzoni
Copy link
Contributor Author

@vapier any chance to get this reviewed/applied ? Thanks!

buildroot-auto-update pushed a commit to buildroot/buildroot that referenced this pull request Mar 12, 2019
Binutils added bfd_stdint.h to bfd.h [1], so elf2flt must create a
symlink for this header. This issue has been fixed upstream in commit
[2].

We keep our local patch
0001-ld-elf2flt-behave-properly-when-called-with-a-name-d.patch as it
still hasn't been merged upstream [3].

Fixes (with binutils 2.23):

  [armv7m-uclibc]        https://gitlab.com/kubu93/toolchains-builder/-/jobs/148356410
  [m68k-coldfire-uclibc] https://gitlab.com/kubu93/toolchains-builder/-/jobs/148356412

[1] https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;a=commitdiff;h=2d5d5a8f0a8b5a03454bf168b7fa7024bb1ebbd8
[2] uclinux-dev/elf2flt@429521f
[3] uclinux-dev/elf2flt#8

Signed-off-by: Romain Naour <romain.naour@gmail.com>
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
@vapier vapier merged commit 1c9b454 into uclinux-dev:master Dec 29, 2019
@vapier
Copy link
Member

vapier commented Dec 29, 2019

thx bud. fell through the cracks ... a few times.

damien-lemoal pushed a commit to damien-lemoal/elf2flt that referenced this pull request Apr 21, 2022
…RGET_ALIAS

ld-elf2flt currently handles two cases:

 1 It is called as the wrapper for <TARGET_ALIAS>-ld, generally
   installed in the bin/ directory of a toolchain.

 2 It is called as the wrapper for "ld", generally installed in the
   TARGET_ALIAS/bin/ directory of a toolchain.

Unfortunately, if for some reason it gets called using a FOOBAR-ld
name that is different from <TARGET_ALIAS>-ld, it assumes it is in
case (2), while it really is in case (1). Due to this, the path
mangling logic doesn't work, and it doesn't find ld.real.

This happens for example when the binary program in bin/ is named
arm-buildroot-uclinux-uclibcgnueabi-ld, but also has a simpler symlink
named arm-linux-ld. In this case,
arm-buildroot-uclinux-uclibcgnueabi-ld is recognized by ld-elf2flt as
containing TARGET_ALIAS, and therefore the proper logic to find
ld.real is applied. However, when arm-linux-ld is used, ld-elf2flt
doesn't find TARGET_ALIAS, and therefore assumes we're being called as
TARGET_ALIAS/bin/ld.. and searches for a program called ld.real in
bin/, which doesn't exist.

See:

$ ./output/host/bin/arm-buildroot-uclinux-uclibcgnueabi-ld
/home/thomas/buildroot/buildroot/output/host/bin/../arm-buildroot-uclinux-uclibcgnueabi/bin/ld.real: no input files

$ ./output/host/bin/arm-linux-ld
arm-linux-ld (ld-elf2flt): error trying to exec '/home/thomas/buildroot/buildroot/output/host/bin/ld.real': execvp: No such file or directory

$ ./output/host/arm-buildroot-uclinux-uclibcgnueabi/bin/ld
/home/thomas/buildroot/buildroot/output/host/arm-buildroot-uclinux-uclibcgnueabi/bin/ld.real: no input files

This commit fixes that by inverting the logic: if we're being called
as just "ld", then we assume it's the program in
TARGET_ALIAS/bin/. Otherwise, we're called through some variant of
TARGET-ld.

Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Submitted-upstream: uclinux-dev#8
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants