mirror of
https://github.com/rui314/mold.git
synced 2024-10-26 13:10:46 +03:00
Compare commits
5 Commits
aa644914fe
...
ec10452b67
Author | SHA1 | Date | |
---|---|---|---|
|
ec10452b67 | ||
|
ba3fd65bcc | ||
|
f816c45b88 | ||
|
ca14cdf9b6 | ||
|
6d667fad45 |
@ -939,11 +939,13 @@ i64 riscv_resize_sections(Context<E> &ctx) {
|
||||
// identified by name. Some extensions are of single-letter alphabet such
|
||||
// as "m" or "q". Newer extension names start with "z" followed by one or
|
||||
// more alphabets (i.e. "zicsr"). "s" and "x" prefixes are reserved
|
||||
// for supervisor- level extensions and private extensions, respectively.
|
||||
// for supervisor-level extensions and private extensions, respectively.
|
||||
//
|
||||
// Each extension consists of a name, a major version and a minor version.
|
||||
// For example, "m2p0" indicates the "m" extension of version 2.0. "p" is
|
||||
// just a separator.
|
||||
// just a separator. Versions are often omitted in documents, but they are
|
||||
// mandatory in .riscv.attributes. Likewise, abbreviations as "g" (which
|
||||
// is short for "IMAFD") are not allowed in .riscv.attributes.
|
||||
//
|
||||
// Each RISC-V object file contains an ISA string enumerating extensions
|
||||
// used by the object file. We need to merge input objects' ISA strings
|
||||
@ -955,7 +957,7 @@ i64 riscv_resize_sections(Context<E> &ctx) {
|
||||
// The following functions takes care of ISA strings.
|
||||
|
||||
struct Extn {
|
||||
std::string_view name;
|
||||
std::string name;
|
||||
i64 major;
|
||||
i64 minor;
|
||||
};
|
||||
@ -1082,12 +1084,12 @@ static std::vector<Extn> merge_extensions(std::span<Extn> x, std::span<Extn> y)
|
||||
}
|
||||
|
||||
static std::string to_string(std::span<Extn> v) {
|
||||
std::string str = std::string(v[0].name) + std::to_string(v[0].major) +
|
||||
"p" + std::to_string(v[0].minor);
|
||||
std::string str = v[0].name + std::to_string(v[0].major) + "p" +
|
||||
std::to_string(v[0].minor);
|
||||
|
||||
for (i64 i = 1; i < v.size(); i++)
|
||||
str += "_" + std::string(v[i].name) + std::to_string(v[i].major) +
|
||||
"p" + std::to_string(v[i].minor);
|
||||
str += "_" + v[i].name + std::to_string(v[i].major) + "p" +
|
||||
std::to_string(v[i].minor);
|
||||
return str;
|
||||
}
|
||||
|
||||
|
@ -355,7 +355,8 @@ static std::vector<ElfPhdr<E>> create_phdr(Context<E> &ctx) {
|
||||
|
||||
// Create a PT_RISCV_ATTRIBUTES
|
||||
if constexpr (is_riscv<E>)
|
||||
define(PT_RISCV_ATTRIBUTES, PF_R, 1, ctx.extra.riscv_attributes);
|
||||
if (ctx.extra.riscv_attributes->shdr.sh_size)
|
||||
define(PT_RISCV_ATTRIBUTES, PF_R, 1, ctx.extra.riscv_attributes);
|
||||
|
||||
// Create a PT_OPENBSD_RANDOMIZE
|
||||
for (Chunk<E> *chunk : ctx.chunks)
|
||||
|
@ -11,6 +11,8 @@ function(add_target TRIPLE)
|
||||
set(HOST arm)
|
||||
elseif(${HOST} STREQUAL "ppc64")
|
||||
set(HOST powerpc64)
|
||||
elseif(${HOST} STREQUAL "ppc64le")
|
||||
set(HOST powerpc64le)
|
||||
endif()
|
||||
|
||||
if(${TRIPLE} MATCHES "${HOST}-.*")
|
||||
|
@ -5,6 +5,9 @@ cat <<EOF | $CC -march=rv64imafd_xfoo1p5 -o $t/a.o -c -xc -
|
||||
void foo() {}
|
||||
EOF
|
||||
|
||||
# The compiler might not create .riscv.attributes
|
||||
readelf --sections $t/a.o | grep -Fq .riscv.attributes || skip
|
||||
|
||||
cat <<EOF | $CC -march=rv64imafd_xfoo2p0 -o $t/b.o -c -xc -
|
||||
void bar() {}
|
||||
EOF
|
||||
|
14
test/elf/riscv64_attributes2.sh
Executable file
14
test/elf/riscv64_attributes2.sh
Executable file
@ -0,0 +1,14 @@
|
||||
#!/bin/bash
|
||||
. $(dirname $0)/common.inc
|
||||
|
||||
cat <<EOF | $CC -o $t/a.o -c -xc -
|
||||
void _start() {}
|
||||
EOF
|
||||
|
||||
$STRIP --remove-section=.riscv.attributes $t/a.o
|
||||
|
||||
$CC -B. -nostdlib -o $t/exe $t/a.o
|
||||
|
||||
readelf -W --segments --sections $t/exe > $t/log
|
||||
! grep -F .riscv.attributes $t/log || false
|
||||
! grep -F RISCV_ATTR $t/log || false
|
Loading…
Reference in New Issue
Block a user