File tree Expand file tree Collapse file tree 3 files changed +31
-17
lines changed
Expand file tree Collapse file tree 3 files changed +31
-17
lines changed Original file line number Diff line number Diff line change @@ -1258,27 +1258,17 @@ void SharedFile<E>::parse(Context<E> &ctx) {
12581258
12591259template <typename E>
12601260std::vector<std::string_view> SharedFile<E>::get_dt_needed(Context<E> &ctx) {
1261- // Get the contents of the dynamic segment
1262- std::span<ElfDyn<E>> dynamic;
1263- for (ElfPhdr<E> &phdr : this ->get_phdrs ())
1264- if (phdr.p_type == PT_DYNAMIC)
1265- dynamic = {(ElfDyn<E> *)(this ->mf ->data + phdr.p_offset ),
1266- (size_t )phdr.p_memsz / sizeof (ElfDyn<E>)};
1267-
1268- // Find a string table
1269- char *strtab = nullptr ;
1270- for (ElfDyn<E> &dyn : dynamic)
1271- if (dyn.d_tag == DT_STRTAB)
1272- strtab = (char *)this ->mf ->data + dyn.d_val ;
1273-
1274- if (!strtab)
1261+ ElfShdr<E> *sec = this ->find_section (SHT_DYNAMIC);
1262+ if (!sec)
12751263 return {};
12761264
1277- // Find all DT_NEEDED entries
1265+ std::span<ElfDyn<E>> dynamic = this ->template get_data <ElfDyn<E>>(ctx, *sec);
1266+ std::string_view strtab = this ->get_string (ctx, sec->sh_link );
1267+
12781268 std::vector<std::string_view> vec;
12791269 for (ElfDyn<E> &dyn : dynamic)
12801270 if (dyn.d_tag == DT_NEEDED)
1281- vec.push_back (strtab + dyn.d_val );
1271+ vec.push_back (strtab. data () + dyn.d_val );
12821272 return vec;
12831273}
12841274
Original file line number Diff line number Diff line change @@ -1086,7 +1086,7 @@ void check_shlib_undefined(Context<E> &ctx) {
10861086
10871087 // Obtain a list of known shared library names.
10881088 std::unordered_set<std::string_view> sonames;
1089- for (SharedFile<E> * file : ctx.dsos )
1089+ for (std::unique_ptr< SharedFile<E>> & file : ctx.dso_pool )
10901090 sonames.insert (file->soname );
10911091
10921092 tbb::parallel_for_each (ctx.dsos , [&](SharedFile<E> *file) {
Original file line number Diff line number Diff line change 1+ #! /bin/bash
2+ . $( dirname $0 ) /common.inc
3+
4+ cat << EOF | $CC -B. -shared -fPIC -o $t /libfoo.so -xc -
5+ void foo() {}
6+ EOF
7+
8+ cat << EOF | $CC -B. -shared -fPIC -o $t /libbar.so -xc - -L$t -lfoo
9+ void foo();
10+ void bar() { foo(); }
11+ EOF
12+
13+ cat << EOF | $CC -c -o $t /a.o -c -xc -
14+ int bar();
15+ int main() { bar(); }
16+ EOF
17+
18+ $CC -B. -o $t /exe1 $t /a.o -Wl,--no-allow-shlib-undefined -L$t -lfoo -lbar
19+ $CC -B. -o $t /exe2 $t /a.o -Wl,--no-allow-shlib-undefined -L$t -lbar
20+
21+ mv $t /libfoo.so $t /libfoo.so.bak
22+ echo | $CC -B. -shared -fPIC -o $t /libfoo.so -xc -
23+
24+ not $CC -B. -o $t /exe3 $t /a.o -Wl,--no-allow-shlib-undefined -L$t -lfoo -lbar
You can’t perform that action at this time.
0 commit comments