Re: GCC Fedora - relocation truncated to fit: R_X86_64_32S against `.rodata'

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

 



On Tue, Dec 20, 2022 at 01:49:00PM +0100, Jakub Jelinek wrote:
> On Tue, Dec 20, 2022 at 12:12:42PM +0000, Daniel P. Berrangé wrote:
> > For KVM AMD SEV-SNP virtualization we're trying to get SVSM guest
> > firmware built on Fedora.
> > 
> >   https://github.com/svsm-vtpm/linux-svsm
> > 
> > It builds successfully on Ubuntu 22.04 (gcc 11.3.0) which is what upstream
> > uses as their primary dev platform. On Fedora 37 (gcc 12.2.1) though, we're
> > getting errors at the final link stage. To eliminate version as a factor,
> > I also tried Fedora 35 with gcc 11.3.1 and got the same errors:
> > 
> > gcc -m64 -nostdlib -Wl,-Tsrc/start/svsm.lds -Wl,--build-id=none -o svsm.bin.elf src/start/start.o target/x86_64-unknown-none/debug/liblinux_svsm.a -Wl,--start-group ./external/build/lib/libtpm.a ./external/build/lib/libplatform.a ./external/build/lib/libwolfssl.a ./external/build/lib/libcrt.a ./external/build/lib/libm.a -Wl,--end-group
> > ./external/build/lib/libwolfssl.a(src_libwolfssl_la-sha256.o): in function `Transform_Sha256':
> > sha256.c:(.text+0xba): relocation truncated to fit: R_X86_64_32 against `.rodata'
> > ./external/build/lib/libwolfssl.a(src_libwolfssl_la-aes.o): in function `wc_AesEncrypt':
> > aes.c:(.text+0x50): relocation truncated to fit: R_X86_64_32S against `.rodata'
> > aes.c:(.text+0x68): relocation truncated to fit: R_X86_64_32S against `.rodata'
> > aes.c:(.text+0x7e): relocation truncated to fit: R_X86_64_32S against `.rodata'
> > aes.c:(.text+0x8c): relocation truncated to fit: R_X86_64_32S against `.rodata'
> > aes.c:(.text+0x9e): relocation truncated to fit: R_X86_64_32S against `.rodata'
> > aes.c:(.text+0xa9): relocation truncated to fit: R_X86_64_32S against `.rodata'
> > aes.c:(.text+0xc5): relocation truncated to fit: R_X86_64_32S against `.rodata'
> > aes.c:(.text+0xd3): relocation truncated to fit: R_X86_64_32S against `.rodata'
> > aes.c:(.text+0xe9): relocation truncated to fit: R_X86_64_32S against `.rodata'
> > aes.c:(.text+0xf8): additional relocation overflows omitted from the output
> > collect2: error: ld returned 1 exit status
> > make: *** [Makefile:54: svsm.bin.elf] Error 1
> 
> That would mean either that your text + data segment are larger than 2GB, or
> src/start/svsm.lds you are using places the sections somewhere high in the
> address space, incompatible with the x86-64 default -mcmodel=small.
> Ubuntu defaults to -fpie -pie like we use in Fedora when hardening isn't
> disabled through specs from redhat-rpm-config, so it uses a different
> code model (small pic).
> You can build stuff with -fpie and link with -pie if you want, or
> -mcmodel=medium or -mcmodel=large etc., depends really on what src/start/svsm.lds
> is doing and how large the binary is.
> As documented:
> '-mcmodel=small'
>      Generate code for the small code model: the program and its symbols
>      must be linked in the lower 2 GB of the address space.  Pointers
>      are 64 bits.  Programs can be statically or dynamically linked.
>      This is the default code model.
> 
> '-mcmodel=medium'
>      Generate code for the medium model: the program is linked in the
>      lower 2 GB of the address space.  Small symbols are also placed
>      there.  Symbols with sizes larger than '-mlarge-data-threshold' are
>      put into large data or BSS sections and can be located above 2GB.
>      Programs can be statically or dynamically linked.
> 
> '-mcmodel=large'
>      Generate code for the large model.  This model makes no assumptions
>      about addresses and sizes of sections.
> etc.

The linker script has:
SECTIONS
{
	. = SVSM_GPA_LDS;
and
#ifndef SVSM_GPA_LDS
#define SVSM_GPA_LDS			0x8000000000
#endif /* SVSM_GPA_LDS */

So, this is indeed incompatible with both small and medium code models,
so everything that is linked into that binary should be compiled with
-mcmodel=large and pay the code performance price for that.

	Jakub
_______________________________________________
devel mailing list -- devel@xxxxxxxxxxxxxxxxxxxxxxx
To unsubscribe send an email to devel-leave@xxxxxxxxxxxxxxxxxxxxxxx
Fedora Code of Conduct: https://docs.fedoraproject.org/en-US/project/code-of-conduct/
List Guidelines: https://fedoraproject.org/wiki/Mailing_list_guidelines
List Archives: https://lists.fedoraproject.org/archives/list/devel@xxxxxxxxxxxxxxxxxxxxxxx
Do not reply to spam, report it: https://pagure.io/fedora-infrastructure/new_issue




[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Fedora Announce]     [Fedora Users]     [Fedora Kernel]     [Fedora Testing]     [Fedora Formulas]     [Fedora PHP Devel]     [Kernel Development]     [Fedora Legacy]     [Fedora Maintainers]     [Fedora Desktop]     [PAM]     [Red Hat Development]     [Gimp]     [Yosemite News]

  Powered by Linux