Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 13 May 2024 20:58:31 GMT
From:      Mike Karels <karels@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org
Subject:   git: 975e833ff730 - releng/14.1 - lld: work around elftoolchain bug which causes bloated RISCV binaries
Message-ID:  <202405132058.44DKwVZg087106@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch releng/14.1 has been updated by karels:

URL: https://cgit.FreeBSD.org/src/commit/?id=975e833ff73005bd3b786de57e037b3bbd15fbab

commit 975e833ff73005bd3b786de57e037b3bbd15fbab
Author:     Dimitry Andric <dim@FreeBSD.org>
AuthorDate: 2024-02-14 19:41:09 +0000
Commit:     Mike Karels <karels@FreeBSD.org>
CommitDate: 2024-05-13 20:58:20 +0000

    lld: work around elftoolchain bug which causes bloated RISCV binaries
    
    The elftoolchain strip(1) command appears to have trouble with the new
    .riscv.attributes sections being added by lld 17 to RISCV binaries. This
    causes huge 'holes' in the files, making them larger than necessary.
    
    Since nothing in the base system uses the new section yet, patch lld to
    leave it out for now.
    
    Direct commit to stable/13, since this intended to go into the 13.3
    release, while the elftoolchain bug is being investigated.
    
    Cherry-pick to stable/14 from stable/13 for the 14.1 release; the
    bug has not been fixed yet.  Hopefully it will be fixed (or the code
    replaced) in time for 14.2.  When that happens, this can be reverted.
    
    Reported by:    karels
    Submitted by:   jrtc27
    Approved by:    re (cperciva)
    
    (cherry picked from commit 42ceb92e6a544fa0956eb660b3c16e38189acf20)
    (cherry picked from commit 8f0bd08e9869ac1e6ad1f0f9c3964a76457cbce1)
---
 contrib/llvm-project/lld/ELF/Writer.cpp | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/contrib/llvm-project/lld/ELF/Writer.cpp b/contrib/llvm-project/lld/ELF/Writer.cpp
index 8a08b0fcc90d..0c1bd27bb1fe 100644
--- a/contrib/llvm-project/lld/ELF/Writer.cpp
+++ b/contrib/llvm-project/lld/ELF/Writer.cpp
@@ -2148,9 +2148,13 @@ template <class ELFT> void Writer<ELFT>::finalizeSections() {
         addPhdrForSection(part, SHT_MIPS_OPTIONS, PT_MIPS_OPTIONS, PF_R);
         addPhdrForSection(part, SHT_MIPS_ABIFLAGS, PT_MIPS_ABIFLAGS, PF_R);
       }
+#if 0
+      // XXX: This stops elftoolchain strip adjusting .riscv.attributes,
+      // leaving large holes in binaries.
       if (config->emachine == EM_RISCV)
         addPhdrForSection(part, SHT_RISCV_ATTRIBUTES, PT_RISCV_ATTRIBUTES,
                           PF_R);
+#endif
     }
     Out::programHeaders->size = sizeof(Elf_Phdr) * mainPart->phdrs.size();
 



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202405132058.44DKwVZg087106>