[PATCH] D33041: [ELF] - Set DF_STATIC_TLS flag for x86_64 target.

George Rimar via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu May 11 05:14:48 PDT 2017


grimar added a comment.

In https://reviews.llvm.org/D33041#751238, @ruiu wrote:

> Can you verify that you actually cannot dlopen() an .so file if the file has the DF_STATIC_TLS flag? I want to make sure that glibc actually uses the flag.


Flag does not seem to have effect for me on Ubuntu 16.04.1 LTS.

Used code:

  #include <iostream>
  #include <dlfcn.h>
  
  int main() {
      std::cout << "Opening test_flag.so...\n";
      void* handle = dlopen("./test_flag.so", RTLD_NOW);
      if (!handle) {
        std::cout << "Cannot open library: " << dlerror() << std::endl;
        return 0;
     }
  
    std::cout << "OK" << std::endl;
    dlclose(handle);
    return 0;
  }

umb at umb-virtual-machine:~/tests/311$ g++ test.cpp -o temp -ldl
umb at umb-virtual-machine:~/tests/311$ ./temp
Opening test_flag.so...
OK    
umb at umb-virtual-machine:~/tests/311$ readelf --dynamic test_flag.so

  Dynamic section at offset 0x228 contains 10 entries:
    Tag        Type                         Name/Value
   0x0000000000000004 (HASH)               0x120
   0x0000000000000005 (STRTAB)             0x1e0
   0x0000000000000006 (SYMTAB)             0x150
   0x000000000000000a (STRSZ)              29 (bytes)
   0x000000000000000b (SYMENT)             24 (bytes)
   0x0000000000000007 (RELA)               0x200
   0x0000000000000008 (RELASZ)             24 (bytes)
   0x0000000000000009 (RELAENT)            24 (bytes)
   0x000000000000001e (FLAGS)              STATIC_TLS
   0x0000000000000000 (NULL)               0x0


https://reviews.llvm.org/D33041





More information about the llvm-commits mailing list