Skip to contentSkip to conversation

/usr/bin/powerpc64-linux-gnu-ld: warning: discarding dynamic section .rela.opd

PATCH Nick Desaulniers 3 participants 4 messages Aug 28, 2020 – Sep 2, 2020 1 message not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 lore raw
Quoted 11 lines · Alan Modra
Quoted 9 lines · Ulrich Weigand

Nick Desaulniers <[email protected]> wrote on 27.08.2020 14:52:36:

Quoted 7 lines
Quoted 3 lines
Quoted 3 lines

All warnings (new ones prefixed by >>):

Quoted 1 line
Quoted 1 line

/usr/bin/powerpc64-linux-gnu-ld: warning: discarding dynamic

section .rela.opd

Quoted 3 lines
Quoted 1 line

We have /DISCARD/ *(.rela*) in the VDSO linker scripts.

Indeed, I see that in arch/powerpc/kernel/vdso64/vdso64.lds.S. Kees, Fangrui, does .rela* not match .rela.opd? That doesn't sound right. Unless it's not the vdso link that's producing the warning? I guess the warning is from GNU BFD, not LLD. Maybe the warning is coming from linking a different object file that doesn't use the same linker script, or perhaps the -T argument is being dropped?

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

What is going on here with clang ?

This warning is from the linker flag --orphan-handling=warn. It's been very handy for us to find bugs for other architectures and Kees has been working on a large series to use it in arm, arm64, and x86.

So the general question is, should we keep the section or discard it, or should it not be produced in the first place?

Quoted 9 lines
Quoted 9 lines
Quoted 5 lines

Looks like .rela.opd was maybe synthesized. cc Dr. Weigand, whos name shows up on llvm/test/MC/PowerPC/ppc64-relocs-01.s, which is the only hit I get in the codebase of opd (at least for tests, still looking to see if ".opd" gets appended somewhere.

Well, this is the old ELFv1 ABI for big-endian PowerPC, which uses function descriptors, which reside in the .opd section. These are emitted by LLVM in the PPCLinuxAsmPrinter::emitFunctionEntryLabel

Ah, "official procedure descriptors" -> opd. Christophe, do we expect the vdso to be ELFv1 ABI? This code in LLVM has two other cases:
1. ppc32
2. ELFv2
If it should not be ELFv1, then something may be amiss in kbuild when building for Clang; maybe Clang has a different command line option for v2 and there's a cc-option check that's silently failing. Maybe clang has a different implicit default than gcc (which should be fixed in clang if so).

The log didn't provide enough info if linking the vdso was the problem. computeTargetABI() in llvm/lib/Target/PowerPC/PPCTargetMachine.cpp seems to imply that ppc64 (big endian) always uses elfv1, unless you specify a machine that starts with "elfv2" in the ABI.

Christophe, did you test your series for big endian and little endian?
Maybe just an issue for big endian?

Quoted 6 lines
Quoted 5 lines

section, and they usually do require relocations since the function descriptor contains the address of the function text (however those relocations should be resolved during final link). I don't think there should be much difference between GCC and LLVM in how those are handled.

Quoted 8 lines

.opd can only be resolved at link time when creating fixed position executables. .opd does need dynamic relocs in PIEs or shared libraries.

Kernel VDSO is rather special though, and I'm not up to speed with whatever hackery the kernel folk use to create it and/or relocate it when the kernel is relocated. Quite possibly the warning should just be ignored.

I'm not sure if the kernel does relocations upon vdso load.

Signature · 2 lines
Thanks,
~Nick Desaulniers
#2 lore raw
Quoted 7 lines · Nick Desaulniers
Quoted 6 lines · Alan Modra
Quoted 4 lines · Ulrich Weigand

Nick Desaulniers <[email protected]> wrote on 27.08.2020 14:52:36:

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

All warnings (new ones prefixed by >>):

Quoted 8 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

/usr/bin/powerpc64-linux-gnu-ld: warning: discarding dynamic

section .rela.opd

Quoted 3 lines
Quoted 1 line

We have /DISCARD/ *(.rela*) in the VDSO linker scripts.

Indeed, I see that in arch/powerpc/kernel/vdso64/vdso64.lds.S. Kees, Fangrui, does .rela* not match .rela.opd? That doesn't sound

It does not. For linker scripts, "*" does not match "." (which is why ".." is sometimes used to keep a subsection out of a "whatever.*" match. X_X

Quoted 25 lines

right. Unless it's not the vdso link that's producing the warning? I guess the warning is from GNU BFD, not LLD. Maybe the warning is coming from linking a different object file that doesn't use the same linker script, or perhaps the -T argument is being dropped?

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

What is going on here with clang ?

This warning is from the linker flag --orphan-handling=warn. It's been very handy for us to find bugs for other architectures and Kees has been working on a large series to use it in arm, arm64, and x86.

So the general question is, should we keep the section or discard it, or should it not be produced in the first place?

Quoted 9 lines
Quoted 9 lines
Quoted 5 lines

Looks like .rela.opd was maybe synthesized. cc Dr. Weigand, whos name shows up on llvm/test/MC/PowerPC/ppc64-relocs-01.s, which is the only hit I get in the codebase of opd (at least for tests, still looking to see if ".opd" gets appended somewhere.

Well, this is the old ELFv1 ABI for big-endian PowerPC, which uses function descriptors, which reside in the .opd section. These are emitted by LLVM in the PPCLinuxAsmPrinter::emitFunctionEntryLabel

Quoted 9 lines

Ah, "official procedure descriptors" -> opd. Christophe, do we expect the vdso to be ELFv1 ABI? This code in LLVM has two other cases:
1. ppc32
2. ELFv2
If it should not be ELFv1, then something may be amiss in kbuild when building for Clang; maybe Clang has a different command line option for v2 and there's a cc-option check that's silently failing. Maybe clang has a different implicit default than gcc (which should be fixed in clang if so).

If it's not produced by bfd, then nothing should be depending on it currently, yes?

Quoted 10 lines
Quoted 8 lines

.opd can only be resolved at link time when creating fixed position executables. .opd does need dynamic relocs in PIEs or shared libraries.

Kernel VDSO is rather special though, and I'm not up to speed with whatever hackery the kernel folk use to create it and/or relocate it when the kernel is relocated. Quite possibly the warning should just be ignored.

I'm not sure if the kernel does relocations upon vdso load.

I won't try to guess about PPC. :) In general, though, the vdso doesn't get a relocation "pass" in that the code page is shared by all processes. So I'd expect rela.opd to be empty or unused. Is it empty in the final image?

Signature · 1 line
Kees Cook
#3 lore raw
Quoted 12 lines · Kees Cook
Quoted 11 lines · Nick Desaulniers
Quoted 10 lines · Alan Modra
Quoted 8 lines · Ulrich Weigand

Nick Desaulniers <[email protected]> wrote on 27.08.2020 14:52:36:

Quoted 6 lines
Quoted 3 lines
Quoted 3 lines

All warnings (new ones prefixed by >>):

Quoted 1 line
Quoted 1 line

/usr/bin/powerpc64-linux-gnu-ld: warning: discarding dynamic

section .rela.opd

Quoted 2 lines
Quoted 1 line
Quoted 8 lines
Quoted 4 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

We have /DISCARD/ *(.rela*) in the VDSO linker scripts.

Indeed, I see that in arch/powerpc/kernel/vdso64/vdso64.lds.S. Kees, Fangrui, does .rela* not match .rela.opd? That doesn't sound

It does not. For linker scripts, "*" does not match "." (which is why ".." is sometimes used to keep a subsection out of a "whatever.*" match. X_X

In linker scripts, "*" matches "."

Is the relocation section from --emit-relocs? --emit-relocs emitted sections are not matched by output section descriptions.

Quoted 25 lines
Quoted 25 lines

right. Unless it's not the vdso link that's producing the warning? I guess the warning is from GNU BFD, not LLD. Maybe the warning is coming from linking a different object file that doesn't use the same linker script, or perhaps the -T argument is being dropped?

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

What is going on here with clang ?

This warning is from the linker flag --orphan-handling=warn. It's been very handy for us to find bugs for other architectures and Kees has been working on a large series to use it in arm, arm64, and x86.

So the general question is, should we keep the section or discard it, or should it not be produced in the first place?

Quoted 9 lines
Quoted 9 lines
Quoted 5 lines

Looks like .rela.opd was maybe synthesized. cc Dr. Weigand, whos name shows up on llvm/test/MC/PowerPC/ppc64-relocs-01.s, which is the only hit I get in the codebase of opd (at least for tests, still looking to see if ".opd" gets appended somewhere.

Well, this is the old ELFv1 ABI for big-endian PowerPC, which uses function descriptors, which reside in the .opd section. These are emitted by LLVM in the PPCLinuxAsmPrinter::emitFunctionEntryLabel

Quoted 9 lines
Quoted 9 lines

Ah, "official procedure descriptors" -> opd. Christophe, do we expect the vdso to be ELFv1 ABI? This code in LLVM has two other cases:
1. ppc32
2. ELFv2
If it should not be ELFv1, then something may be amiss in kbuild when building for Clang; maybe Clang has a different command line option for v2 and there's a cc-option check that's silently failing. Maybe clang has a different implicit default than gcc (which should be fixed in clang if so).

LLD does not have ppc64 ELF v1 support. It had incomplete support which was removed
https://reviews.llvm.org/D46316
I know very little about ELF v1, but I can tell that R_PPC64_REL24 has different semantics with ELF v1, which will assuredly be broken by LLD.

Quoted 18 lines

If it's not produced by bfd, then nothing should be depending on it currently, yes?

Quoted 10 lines
Quoted 8 lines

.opd can only be resolved at link time when creating fixed position executables. .opd does need dynamic relocs in PIEs or shared libraries.

Kernel VDSO is rather special though, and I'm not up to speed with whatever hackery the kernel folk use to create it and/or relocate it when the kernel is relocated. Quite possibly the warning should just be ignored.

I'm not sure if the kernel does relocations upon vdso load.

I won't try to guess about PPC. :) In general, though, the vdso doesn't get a relocation "pass" in that the code page is shared by all processes. So I'd expect rela.opd to be empty or unused. Is it empty in the final image?

#4 lore raw
Quoted 19 lines · Fangrui Song
Quoted 17 lines · Kees Cook
Quoted 15 lines · Nick Desaulniers
Quoted 11 lines · Alan Modra
Quoted 9 lines · Ulrich Weigand

Nick Desaulniers <[email protected]> wrote on 27.08.2020 14:52:36:

Quoted 7 lines
Quoted 3 lines
Quoted 3 lines

All warnings (new ones prefixed by >>):

Quoted 1 line
Quoted 1 line

/usr/bin/powerpc64-linux-gnu-ld: warning: discarding dynamic

section .rela.opd

Quoted 3 lines
Quoted 1 line

We have /DISCARD/ *(.rela*) in the VDSO linker scripts.

Indeed, I see that in arch/powerpc/kernel/vdso64/vdso64.lds.S. Kees, Fangrui, does .rela* not match .rela.opd? That doesn't sound

Quoted 33 lines
Quoted 3 lines

It does not. For linker scripts, "*" does not match "." (which is why ".." is sometimes used to keep a subsection out of a "whatever.*" match. X_X

In linker scripts, "*" matches "."

Is the relocation section from --emit-relocs? --emit-relocs emitted sections are not matched by output section descriptions.

Quoted 24 lines
Quoted 24 lines

right. Unless it's not the vdso link that's producing the warning? I guess the warning is from GNU BFD, not LLD. Maybe the warning is coming from linking a different object file that doesn't use the same linker script, or perhaps the -T argument is being dropped?

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

What is going on here with clang ?

This warning is from the linker flag --orphan-handling=warn. It's been very handy for us to find bugs for other architectures and Kees has been working on a large series to use it in arm, arm64, and x86.

So the general question is, should we keep the section or discard it, or should it not be produced in the first place?

Quoted 9 lines
Quoted 9 lines
Quoted 5 lines

Looks like .rela.opd was maybe synthesized. cc Dr. Weigand, whos name shows up on llvm/test/MC/PowerPC/ppc64-relocs-01.s, which is the only hit I get in the codebase of opd (at least for tests, still looking to see if ".opd" gets appended somewhere.

Well, this is the old ELFv1 ABI for big-endian PowerPC, which uses function descriptors, which reside in the .opd section. These are emitted by LLVM in the PPCLinuxAsmPrinter::emitFunctionEntryLabel

Then this sounds like just another case where big endian support in LLD is generally broken and should be disabled or unselectable in Kconfig.

Quoted 34 lines
Quoted 10 lines
Quoted 10 lines

Ah, "official procedure descriptors" -> opd. Christophe, do we expect the vdso to be ELFv1 ABI? This code in LLVM has two other cases:
1. ppc32
2. ELFv2
If it should not be ELFv1, then something may be amiss in kbuild when building for Clang; maybe Clang has a different command line option for v2 and there's a cc-option check that's silently failing. Maybe clang has a different implicit default than gcc (which should be fixed in clang if so).

LLD does not have ppc64 ELF v1 support. It had incomplete support which was removed
https://reviews.llvm.org/D46316
I know very little about ELF v1, but I can tell that R_PPC64_REL24 has different semantics with ELF v1, which will assuredly be broken by LLD.

Quoted 18 lines

If it's not produced by bfd, then nothing should be depending on it currently, yes?

Quoted 10 lines
Quoted 8 lines

.opd can only be resolved at link time when creating fixed position executables. .opd does need dynamic relocs in PIEs or shared libraries.

Kernel VDSO is rather special though, and I'm not up to speed with whatever hackery the kernel folk use to create it and/or relocate it when the kernel is relocated. Quite possibly the warning should just be ignored.

I'm not sure if the kernel does relocations upon vdso load.

I won't try to guess about PPC. :) In general, though, the vdso doesn't get a relocation "pass" in that the code page is shared by all processes. So I'd expect rela.opd to be empty or unused. Is it empty in the final image?

Signature · 2 lines
Thanks,
~Nick Desaulniers