Page MenuHomePhabricator

[compiler-rt] Fix a broken asan 64-bit test using ld_preload

Authored by etienneb on Sep 22 2016, 12:04 PM.



The '' is not working with the i686 architecture.
To repro the error, run on a linux 64-bit:

ninja check-asan-dynamic

The following error occurs:

Exit Code: 1

Command Output (stderr):
/home/llvm/llvm/projects/compiler-rt/test/asan/TestCases/Linux/ error: expected string not found in input
 // CHECK: AddressSanitizer: heap-buffer-overflow
<stdin>:1:1: note: scanning from here
ERROR: object '' from LD_PRELOAD cannot be preloaded (wrong ELF class: ELFCLASS32): ignored.
<stdin>:2:10: note: possible intended match here
==25982==AddressSanitizer CHECK failed: /home/llvm/llvm/projects/compiler-rt/lib/asan/ "((__interception::real_memcpy)) != (0)" (0x0, 0x0)

The unittest is running (where %shared_libasan is replaced by

// RUN: env LD_PRELOAD=%shared_libasan not %run %t 2>&1 | FileCheck %s

But the executable also has a dependancy on (added by the clang driver): =>  (0xf77cc000) => not found => /usr/lib/i386-linux-gnu/ (0xf76ba000) => /lib/i386-linux-gnu/ (0xf7673000) => /lib/i386-linux-gnu/ (0xf7656000) => /lib/i386-linux-gnu/ (0xf74a7000)

By looking to the clang driver (tools.cpp) we can see that every x86 architecture are mapped to 'i386'.

StringRef MyArch;
   switch (getToolChain().getArch()) {
   case llvm::Triple::arm:
     MyArch = "arm";
   case llvm::Triple::x86:
     MyArch = "i386";
   case llvm::Triple::x86_64:
     MyArch = "amd64";
     llvm_unreachable("Unsupported architecture");

This patch is implementing the same mapping but in the compiler-rt unittest.

Diff Detail

Event Timeline

etienneb updated this revision to Diff 72199.Sep 22 2016, 12:04 PM
etienneb retitled this revision from to [compiler-rt] Fix a broken asan 64-bit test using ld_preload.
etienneb updated this object.
etienneb added reviewers: rnk, vitalybuka.
etienneb added subscribers: chrisha, llvm-commits.
etienneb updated this revision to Diff 72200.Sep 22 2016, 12:07 PM

fix comment

vitalybuka accepted this revision.Sep 23 2016, 10:29 AM
vitalybuka edited edge metadata.


This revision is now accepted and ready to land.Sep 23 2016, 10:29 AM
etienneb closed this revision.Sep 23 2016, 10:49 AM