diff --git a/src/output-chunks.cc b/src/output-chunks.cc index 292677f3ab..5d87cfe329 100644 --- a/src/output-chunks.cc +++ b/src/output-chunks.cc @@ -1761,7 +1761,8 @@ static u64 get_symbol_size(Symbol &sym) { if (esym.st_size > 0) if (InputSection *isec = sym.get_input_section()) if (!isec->extra.r_deltas.empty()) - return esym.st_size - get_r_delta(*isec, esym.st_value + esym.st_size); + return esym.st_size + esym.st_value - sym.value - + get_r_delta(*isec, esym.st_value + esym.st_size); return esym.st_size; } diff --git a/test/arch-riscv64-symbol-size.sh b/test/arch-riscv64-symbol-size.sh index 1c1712bc22..641b26dd26 100755 --- a/test/arch-riscv64-symbol-size.sh +++ b/test/arch-riscv64-symbol-size.sh @@ -2,27 +2,39 @@ . $(dirname $0)/common.inc cat < int get_foo(); -int main() { printf("%x\n", get_foo()); } +int get_bar(); +int main() { printf("%x %x\n", get_foo(), get_bar()); } EOF $CC -B. -o $t/exe $t/a.o $t/b.o $t/c.o readelf --syms $t/a.o | grep -Eq ' 10 FUNC .* get_foo$' +readelf --syms $t/a.o | grep -Eq ' 10 FUNC .* get_bar$' + readelf --syms $t/exe | grep -Eq ' 8 FUNC .* get_foo$' +readelf --syms $t/exe | grep -Eq ' 8 FUNC .* get_bar$'