diff mbox series

[v2,2/3] build32: don't discard .shstrtab in linker script

Message ID 20200528144023.10814-3-roger.pau@citrix.com (mailing list archive)
State New, archived
Headers show
Series Clang/LLVM build fixes | expand

Commit Message

Roger Pau Monne May 28, 2020, 2:40 p.m. UTC
LLVM linker doesn't support discarding .shstrtab, and complains with:

ld -melf_i386_fbsd -N -T build32.lds -o reloc.lnk reloc.o
ld: error: discarding .shstrtab section is not allowed

Add an explicit .shstrtab section to the linker script after the text
section in order to make LLVM LD happy.

Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
---
 xen/arch/x86/boot/build32.lds | 5 +++++
 1 file changed, 5 insertions(+)

Comments

Jan Beulich May 29, 2020, 3:45 p.m. UTC | #1
On 28.05.2020 16:40, Roger Pau Monne wrote:
> LLVM linker doesn't support discarding .shstrtab, and complains with:
> 
> ld -melf_i386_fbsd -N -T build32.lds -o reloc.lnk reloc.o
> ld: error: discarding .shstrtab section is not allowed

Well, yes, GNU ld is more intelligent and doesn't extend the
discarding to the control sections in the first place. All
of .symtab, .strtab, and .shstrtab are still there.

> Add an explicit .shstrtab section to the linker script after the text
> section in order to make LLVM LD happy.
> 
> Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>

Assuming the change was tested to not confuse GNU ld
Acked-by: Jan Beulich <jbeulich@suse.com>

I wouldn't mind extending this to the other two control
sections named above. In case the binaries need picking
apart, them being present is surely helpful.

Jan
Roger Pau Monne June 1, 2020, 9:12 a.m. UTC | #2
On Fri, May 29, 2020 at 05:45:44PM +0200, Jan Beulich wrote:
> On 28.05.2020 16:40, Roger Pau Monne wrote:
> > LLVM linker doesn't support discarding .shstrtab, and complains with:
> > 
> > ld -melf_i386_fbsd -N -T build32.lds -o reloc.lnk reloc.o
> > ld: error: discarding .shstrtab section is not allowed
> 
> Well, yes, GNU ld is more intelligent and doesn't extend the
> discarding to the control sections in the first place. All
> of .symtab, .strtab, and .shstrtab are still there.
> 
> > Add an explicit .shstrtab section to the linker script after the text
> > section in order to make LLVM LD happy.
> > 
> > Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
> 
> Assuming the change was tested to not confuse GNU ld
> Acked-by: Jan Beulich <jbeulich@suse.com>

Yes, it's been tested on the gitlab CI, no issues reported on any of
the builds:

https://gitlab.com/xen-project/people/royger/xen/pipelines/151009839

> I wouldn't mind extending this to the other two control
> sections named above. In case the binaries need picking
> apart, them being present is surely helpful.

I don't mind extending, it might make sense in case linkers start
complaining about trying to discard those too.

Thanks, Roger.
diff mbox series

Patch

diff --git a/xen/arch/x86/boot/build32.lds b/xen/arch/x86/boot/build32.lds
index 97454b40ff..5bd42ee4d9 100644
--- a/xen/arch/x86/boot/build32.lds
+++ b/xen/arch/x86/boot/build32.lds
@@ -50,6 +50,11 @@  SECTIONS
         *(.got.plt)
   }
 
+  .shstrtab : {
+        /* Discarding .shstrtab is not supported by LLD (LLVM LD). */
+        *(.shstrtab)
+  }
+
   /DISCARD/ : {
         /*
          * Discard everything else, to prevent linkers from putting