[llvm-bugs] [Bug 45797] New: .dynsym reference in linked DSO should not bring in STV_HIDDEN symbol from archive

via llvm-bugs llvm-bugs at lists.llvm.org
Mon May 4 14:41:12 PDT 2020


https://bugs.llvm.org/show_bug.cgi?id=45797

            Bug ID: 45797
           Summary: .dynsym reference in linked DSO should not bring in
                    STV_HIDDEN symbol from archive
           Product: lld
           Version: unspecified
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: ELF
          Assignee: unassignedbugs at nondot.org
          Reporter: roland at hack.frob.com
                CC: llvm-bugs at lists.llvm.org, smithp352 at googlemail.com

```
echo > libimpl.c 'void impl_symbol() {}'                                        
echo > libapi.c 'void impl_symbol(); void api_symbol() { impl_symbol(); }'      
echo > plugin.c 'void api_symbol(); void plugin_symbol() { api_symbol(); }'     

clang -fPIC -shared -o libimpl.so -Wl,-soname,libimpl.so libimpl.c              
clang -fPIC -shared -o libapi.so -Wl,-soname,libapi.so libapi.c libimpl.so      

clang -fPIC -c -o libimpl-public.o libimpl.c                                    
ar cq libimpl-public.a                                                          

clang -fPIC -c -fvisibility=hidden -o libimpl-hermetic.o libimpl.c              
ar cq libimpl-hermetic.a                                                        

clang -fPIC -c plugin.c                                                         

for linker in lld gold bfd; do                                                  
  ld.$linker -o plugin-preempts.$linker -shared plugin.o --start-group
libimpl-public.a libapi.so --end-group                                          
  ld.$linker -o plugin-hermetic.$linker -shared plugin.o --start-group
libimpl-hermetic.a libapi.so --end-group                                        
done                                                                            

readelf -Ws plugin-preempts.lld                                                 
#    3: 0000000000001370     6 FUNC    GLOBAL DEFAULT    7 impl_symbol          
# as expected: impl_symbol is public and libapi.so has UND impl_symbol so       
# it preempts libimpl.so.  GNU linkers behave the same.                         

readelf -Ws plugin-hermetic.lld                                                 
#    3: 0000000000001340     6 FUNC    LOCAL  HIDDEN     7 impl_symbol          
# should not be there, it's pure dead code!                                     
# BFD behaves the same (buggy), but Gold does not (correct).                    
#                                                                               
# An STV_HIDDEN symbol can never satisfy a DSO's reference, so it should        
# not be brought into the link from an archive (nor preserved from GC if        
# brought in otherwise) because of such a reference.                            

```

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20200504/60ca024b/attachment-0001.html>


More information about the llvm-bugs mailing list