[PATCH] D55878: [Driver] Use --hash-style=gnu instead of both on FreeBSD

Fangrui Song via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Dec 18 21:59:37 PST 2018


MaskRay created this revision.
MaskRay added reviewers: emaste, brooks, dim.
Herald added subscribers: cfe-commits, atanasyan, fedor.sergeev, arichardson, sdardis.

rtld started to support DT_GNU_HASH since rS234841 (2013).
libexec/rtld-elf/rtld.c:symlook_obj uses DT_GNU_HASH when it is present and ignores DT_HASH.
This saves a few hundreds bytes to a few kilobytes for typical executables. (DT_HASH is usually larger than DT_GNU_HASH because it does not skip undefined dynsym entries)

Also delete historical special case for MIPS.


Repository:
  rC Clang

https://reviews.llvm.org/D55878

Files:
  lib/Driver/ToolChains/FreeBSD.cpp
  test/Driver/freebsd.c


Index: test/Driver/freebsd.c
===================================================================
--- test/Driver/freebsd.c
+++ test/Driver/freebsd.c
@@ -73,38 +73,10 @@
 // RUN: %clang -no-canonical-prefixes -target x86_64-pc-freebsd10.0 -m32 %s \
 // RUN:   --sysroot=%S/Inputs/multiarch_freebsd64_tree -### 2>&1 \
 // RUN:   | FileCheck --check-prefix=CHECK-LDFLAGS9 %s
-// CHECK-LDFLAGS8-NOT: --hash-style=both
+// CHECK-LDFLAGS8-NOT: --hash-style=gnu
 // CHECK-LDFLAGS8: --enable-new-dtags
-// CHECK-LDFLAGS9: --hash-style=both
+// CHECK-LDFLAGS9: --hash-style=gnu
 // CHECK-LDFLAGS9: --enable-new-dtags
-//
-// Check that we do not pass --hash-style=gnu and --hash-style=both to linker
-// and provide correct path to the dynamic linker for MIPS platforms.
-// Also verify that we tell the assembler to target the right ISA and ABI.
-// RUN: %clang %s -### -o %t.o 2>&1 \
-// RUN:     -target mips-unknown-freebsd10.0 \
-// RUN:   | FileCheck --check-prefix=CHECK-MIPS %s
-// CHECK-MIPS: "{{[^" ]*}}ld{{[^" ]*}}"
-// CHECK-MIPS: "-dynamic-linker" "{{.*}}/libexec/ld-elf.so.1"
-// CHECK-MIPS-NOT: "--hash-style={{gnu|both}}"
-// RUN: %clang %s -### -o %t.o 2>&1 \
-// RUN:     -target mipsel-unknown-freebsd10.0 \
-// RUN:   | FileCheck --check-prefix=CHECK-MIPSEL %s
-// CHECK-MIPSEL: "{{[^" ]*}}ld{{[^" ]*}}"
-// CHECK-MIPSEL: "-dynamic-linker" "{{.*}}/libexec/ld-elf.so.1"
-// CHECK-MIPSEL-NOT: "--hash-style={{gnu|both}}"
-// RUN: %clang %s -### 2>&1 \
-// RUN:     -target mips64-unknown-freebsd10.0 \
-// RUN:   | FileCheck --check-prefix=CHECK-MIPS64 %s
-// CHECK-MIPS64: "{{[^" ]*}}ld{{[^" ]*}}"
-// CHECK-MIPS64: "-dynamic-linker" "{{.*}}/libexec/ld-elf.so.1"
-// CHECK-MIPS64-NOT: "--hash-style={{gnu|both}}"
-// RUN: %clang %s -### 2>&1 \
-// RUN:     -target mips64el-unknown-freebsd10.0 \
-// RUN:   | FileCheck --check-prefix=CHECK-MIPS64EL %s
-// CHECK-MIPS64EL: "{{[^" ]*}}ld{{[^" ]*}}"
-// CHECK-MIPS64EL: "-dynamic-linker" "{{.*}}/libexec/ld-elf.so.1"
-// CHECK-MIPS64EL-NOT: "--hash-style={{gnu|both}}"
 
 // RUN: %clang -no-canonical-prefixes -target x86_64-pc-freebsd8 -static %s \
 // RUN:   --sysroot=%S/Inputs/multiarch_freebsd64_tree -### 2>&1 \
Index: lib/Driver/ToolChains/FreeBSD.cpp
===================================================================
--- lib/Driver/ToolChains/FreeBSD.cpp
+++ lib/Driver/ToolChains/FreeBSD.cpp
@@ -156,12 +156,8 @@
       CmdArgs.push_back("-dynamic-linker");
       CmdArgs.push_back("/libexec/ld-elf.so.1");
     }
-    if (ToolChain.getTriple().getOSMajorVersion() >= 9) {
-      if (Arch == llvm::Triple::arm || Arch == llvm::Triple::sparc ||
-          Arch == llvm::Triple::x86 || Arch == llvm::Triple::x86_64) {
-        CmdArgs.push_back("--hash-style=both");
-      }
-    }
+    if (ToolChain.getTriple().getOSMajorVersion() >= 9)
+      CmdArgs.push_back("--hash-style=gnu");
     CmdArgs.push_back("--enable-new-dtags");
   }
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D55878.178835.patch
Type: text/x-patch
Size: 2906 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20181219/f98d248b/attachment.bin>


More information about the cfe-commits mailing list