Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 825282 - dev-lang/ocaml-4.12.1: contain runtime text relocations and Unrecognized ELF file(s)
Summary: dev-lang/ocaml-4.12.1: contain runtime text relocations and Unrecognized ELF ...
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: riscv Linux
: Normal normal
Assignee: Gentoo Team for the ML programming language family
URL: https://github.com/ocaml/ocaml/pull/1...
Whiteboard:
Keywords:
Depends on:
Blocks: riscv-keywording
  Show dependency tree
 
Reported: 2021-11-20 11:43 UTC by Alex Fan
Modified: 2022-02-25 19:58 UTC (History)
3 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
build log (ocaml-4.12.1:20211120-054629.log.xz,59.11 KB, application/x-xz)
2021-11-20 12:02 UTC, Alex Fan
Details
emerge --info (emerge.info,5.64 KB, text/plain)
2021-11-20 12:02 UTC, Alex Fan
Details
ocaml-4.12.1-fix-textrel-riscv.patch (ocaml-4.12.1-fix-textrel-riscv.patch,1.74 KB, patch)
2022-02-22 08:59 UTC, Alex Fan
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Alex Fan archtester 2021-11-20 11:43:06 UTC
reproducible on both Sifive Unmatched board and qemu riscv64 environment.

 * QA Notice: The following files contain runtime text relocations                                                  
 *  Text relocations force the dynamic linker to perform extra
 *  work at startup, waste system resources, and may pose a security
 *  risk.  On some architectures, the code may not even function
 *  properly, if at all.                                  
 *  For more information, see:                                                                                      
 *                                                                                                                  
 *    https://wiki.gentoo.org/wiki/Hardened/HOWTO_locate_and_fix_textrels                                           
 *                                                                                                                  
 *  Please include the following list of files in your report:
 * TEXTREL usr/lib64/ocaml/str.cmxs                       
 * TEXTREL usr/lib64/ocaml/unix.cmxs                                                                                
 * TEXTREL usr/bin/ocamllex.opt                           
 * TEXTREL usr/bin/ocamlopt.opt                           
 * TEXTREL usr/bin/ocamlc.opt                             
 * TEXTREL usr/bin/ocamldoc.opt
 * TEXTREL usr/bin/ocamlcmt
 * TEXTREL usr/bin/ocamlobjinfo.opt
 * TEXTREL usr/bin/ocamlmktop.opt
 * TEXTREL usr/bin/ocamlmklib.opt
 * TEXTREL usr/bin/ocamloptp.opt
 * TEXTREL usr/bin/ocamlcp.opt
 * TEXTREL usr/bin/ocamlprof.opt
 * TEXTREL usr/bin/ocamldep.opt


QA Notice: Unrecognized ELF file(s):

RISCV;/usr/lib/debug/usr/lib64/ocaml/profiling.o.debug
RISCV;/usr/lib/debug/usr/lib64/ocaml/compiler-libs/optmain.o.debug
RISCV;/usr/lib/debug/usr/lib64/ocaml/compiler-libs/main.o.debug
RISCV;/usr/lib/debug/usr/lib64/ocaml/std_exit.o.debug
RISCV;/usr/lib64/ocaml/profiling.o
RISCV;/usr/lib64/ocaml/std_exit.o
RISCV;/usr/lib64/ocaml/compiler-libs/optmain.o
RISCV;/usr/lib64/ocaml/compiler-libs/main.o

Reproducible: Always
Comment 1 Alex Fan archtester 2021-11-20 12:02:11 UTC
Created attachment 753886 [details]
build log
Comment 2 Alex Fan archtester 2021-11-20 12:02:36 UTC
Created attachment 753890 [details]
emerge --info
Comment 3 Alex Fan archtester 2021-11-20 12:22:55 UTC
This could be fixed temporally by append-ldflags "-Wl,-z,notext like 32 bits arches, but the case for riscv64 is different from bug #773226. According to upstream, ocaml supports generating PIC on riscv64. 

> scanelf -qT str.cmxs
...
  str.cmxs: (memory/data?) [r_offset=0x10F58] r_type=3 in (optimized out: previous camlStr__frametable) [closest_prev_sym=0xEED8]
  str.cmxs: (memory/data?) [r_offset=0x10F68] r_type=3 in (optimized out: previous camlStr__frametable) [closest_prev_sym=0xEED8]
  str.cmxs: (memory/data?) [r_offset=0x10F80] r_type=3 in (optimized out: previous camlStr__frametable) [closest_prev_sym=0xEED8]
...

r_type=3 is R_RISCV_RELATIVE

Also, previously (portage tree is on around 2021.10.09), many tests failed with "warning: creating DT_TEXTREL in a PIE". But now no test failures appear with current portage tree.
Comment 4 Alex Fan archtester 2022-02-22 08:59:39 UTC
Created attachment 765628 [details, diff]
ocaml-4.12.1-fix-textrel-riscv.patch
Comment 5 Larry the Git Cow gentoo-dev 2022-02-25 19:58:31 UTC
The bug has been closed via the following commit(s):

https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=85fb0c39c57aae6d7795b6ee1259d53ecfebd882

commit 85fb0c39c57aae6d7795b6ee1259d53ecfebd882
Author:     Alfredo Tupone <tupone@gentoo.org>
AuthorDate: 2022-02-25 19:58:12 +0000
Commit:     Alfredo Tupone <tupone@gentoo.org>
CommitDate: 2022-02-25 19:58:12 +0000

    dev-lang/ocaml: fix TEXTREL on 4.12.1
    
    Closes: https://bugs.gentoo.org/825282
    Package-Manager: Portage-3.0.30, Repoman-3.0.3
    Signed-off-by: Alfredo Tupone <tupone@gentoo.org>

 .../files/ocaml-4.12.1-fix-textrel-riscv.patch     | 46 ++++++++++++++++++++++
 dev-lang/ocaml/ocaml-4.12.1.ebuild                 |  1 +
 2 files changed, 47 insertions(+)