public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug sanitizer/55599] New: switch from mach_override to mac interpose function support in libasan broke -static-libasan
@ 2012-12-05  0:01 howarth at nitro dot med.uc.edu
  2012-12-05  0:07 ` [Bug sanitizer/55599] " howarth at nitro dot med.uc.edu
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: howarth at nitro dot med.uc.edu @ 2012-12-05  0:01 UTC (permalink / raw)
  To: gcc-bugs


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55599

             Bug #: 55599
           Summary: switch from mach_override to mac interpose function
                    support in libasan broke -static-libasan
    Classification: Unclassified
           Product: gcc
           Version: 4.8.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: sanitizer
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: howarth@nitro.med.uc.edu
                CC: dodji@gcc.gnu.org, dvyukov@gcc.gnu.org,
                    jakub@gcc.gnu.org, kcc@gcc.gnu.org


After r194120, the -static-libasan option fails to find the required symbols
for linking libasan.a on x86_64-apple-darwin12. For example...

% g++-fsf-4.8 -g -static-libasan -fsanitize=address cond1.C
Undefined symbols for architecture x86_64:
  "__interception::OverrideFunction(unsigned long, unsigned long, unsigned
long*)", referenced from:
      __asan::InitializeMacInterceptors()      in libasan.a(asan_mac.o)
ld: symbol(s) not found for architecture x86_64
collect2: error: ld returned 1 exit status

% nm libasan.0.dylib  | grep OverrideFunction
                 U __ZN14__interception16OverrideFunctionEmmPm

% nm libasan.a | grep OverrideFunction
                 U __ZN14__interception16OverrideFunctionEmmPm

Oddly when compiling normally against the dynamic library...

% g++-fsf-4.8 -g -fsanitize=address cond1.C
% nm ./a.out | grep OverrideFunction
% ./a.out
%

...the resulting executable links in libasan.0.dylib but doesn't complain about
the undefined symbol on execution.


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug sanitizer/55599] switch from mach_override to mac interpose function support in libasan broke -static-libasan
  2012-12-05  0:01 [Bug sanitizer/55599] New: switch from mach_override to mac interpose function support in libasan broke -static-libasan howarth at nitro dot med.uc.edu
@ 2012-12-05  0:07 ` howarth at nitro dot med.uc.edu
  2012-12-05  1:07 ` glider at google dot com
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: howarth at nitro dot med.uc.edu @ 2012-12-05  0:07 UTC (permalink / raw)
  To: gcc-bugs


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55599

--- Comment #1 from Jack Howarth <howarth at nitro dot med.uc.edu> 2012-12-05 00:07:04 UTC ---
I assume that the mechanism for mac function imposition prohibits the use of a
static libasan? If so we should remove the support for -static-libasan from
gcc/config/darwin.h.


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug sanitizer/55599] switch from mach_override to mac interpose function support in libasan broke -static-libasan
  2012-12-05  0:01 [Bug sanitizer/55599] New: switch from mach_override to mac interpose function support in libasan broke -static-libasan howarth at nitro dot med.uc.edu
  2012-12-05  0:07 ` [Bug sanitizer/55599] " howarth at nitro dot med.uc.edu
@ 2012-12-05  1:07 ` glider at google dot com
  2012-12-05  3:47 ` howarth at nitro dot med.uc.edu
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: glider at google dot com @ 2012-12-05  1:07 UTC (permalink / raw)
  To: gcc-bugs


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55599

--- Comment #2 from Alexander Potapenko <glider at google dot com> 2012-12-05 01:07:36 UTC ---
Not that it prohibits the use of static ASan, they just currently can't coexist
in a single program with the current setup. It is theoretically possible to
have them both, although we definitely do not want to.
I'm guessing that the link problems have been caused by the removal of
mach_override from the tree.


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug sanitizer/55599] switch from mach_override to mac interpose function support in libasan broke -static-libasan
  2012-12-05  0:01 [Bug sanitizer/55599] New: switch from mach_override to mac interpose function support in libasan broke -static-libasan howarth at nitro dot med.uc.edu
  2012-12-05  0:07 ` [Bug sanitizer/55599] " howarth at nitro dot med.uc.edu
  2012-12-05  1:07 ` glider at google dot com
@ 2012-12-05  3:47 ` howarth at nitro dot med.uc.edu
  2012-12-05  4:01 ` kcc at gcc dot gnu.org
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: howarth at nitro dot med.uc.edu @ 2012-12-05  3:47 UTC (permalink / raw)
  To: gcc-bugs


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55599

--- Comment #3 from Jack Howarth <howarth at nitro dot med.uc.edu> 2012-12-05 03:46:59 UTC ---
I suspect that for the FSF gcc build, the static libasan library has identical
code to that in the dynamic libasan but compiled as a static library. FSF gcc
wouldn't know to do any tricks like building the dynamic libasan with mac
function imposition code and static libasan with mach_override code. I am still
unclear if the mac function imposition method itself requires a shared library
to be used for the libasan code. If that is in fact the case, we likely won't
have functional static libasan support on darwin since mach_override will
eventually be deprecated, no?


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug sanitizer/55599] switch from mach_override to mac interpose function support in libasan broke -static-libasan
  2012-12-05  0:01 [Bug sanitizer/55599] New: switch from mach_override to mac interpose function support in libasan broke -static-libasan howarth at nitro dot med.uc.edu
                   ` (2 preceding siblings ...)
  2012-12-05  3:47 ` howarth at nitro dot med.uc.edu
@ 2012-12-05  4:01 ` kcc at gcc dot gnu.org
  2012-12-05  4:51 ` glider at google dot com
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: kcc at gcc dot gnu.org @ 2012-12-05  4:01 UTC (permalink / raw)
  To: gcc-bugs


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55599

--- Comment #4 from Kostya Serebryany <kcc at gcc dot gnu.org> 2012-12-05 04:01:41 UTC ---
the interpose thing can not be linked statically, afaict. 
So, let's just drop -static-libasan from darwin.


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug sanitizer/55599] switch from mach_override to mac interpose function support in libasan broke -static-libasan
  2012-12-05  0:01 [Bug sanitizer/55599] New: switch from mach_override to mac interpose function support in libasan broke -static-libasan howarth at nitro dot med.uc.edu
                   ` (3 preceding siblings ...)
  2012-12-05  4:01 ` kcc at gcc dot gnu.org
@ 2012-12-05  4:51 ` glider at google dot com
  2012-12-05  6:11 ` kcc at gcc dot gnu.org
  2012-12-08 19:06 ` howarth at nitro dot med.uc.edu
  6 siblings, 0 replies; 8+ messages in thread
From: glider at google dot com @ 2012-12-05  4:51 UTC (permalink / raw)
  To: gcc-bugs


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55599

--- Comment #5 from Alexander Potapenko <glider at google dot com> 2012-12-05 04:50:43 UTC ---
The dynamic interposition library is based on the __DATA,__interpose dyld
feature (see http://toves.freeshell.org/interpose/ or Amit Singh's "Mac OS X
Internals" book), which strictly requires the interposing functions to be in a
shared library that must be preloaded using DYLD_INSERT_LIBRARIES (ASan does
that automatically in __asan_init)
The dynamic library doesn't require the mach_override code (we don't link it in
LLVM), but the static one does. Since you have removed the mach_override code,
it's time to drop the static library support (note that in LLVM the static
runtime library is still the default one, because it's now the one that simply
works)


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug sanitizer/55599] switch from mach_override to mac interpose function support in libasan broke -static-libasan
  2012-12-05  0:01 [Bug sanitizer/55599] New: switch from mach_override to mac interpose function support in libasan broke -static-libasan howarth at nitro dot med.uc.edu
                   ` (4 preceding siblings ...)
  2012-12-05  4:51 ` glider at google dot com
@ 2012-12-05  6:11 ` kcc at gcc dot gnu.org
  2012-12-08 19:06 ` howarth at nitro dot med.uc.edu
  6 siblings, 0 replies; 8+ messages in thread
From: kcc at gcc dot gnu.org @ 2012-12-05  6:11 UTC (permalink / raw)
  To: gcc-bugs


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55599

--- Comment #6 from Kostya Serebryany <kcc at gcc dot gnu.org> 2012-12-05 06:10:31 UTC ---
>> note that in LLVM the static runtime library is still the default one, 
>> because it's now the one that simply works
But once we switch to interpose (soon, hopefully) mach_override will be gone
from LLVM too.


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug sanitizer/55599] switch from mach_override to mac interpose function support in libasan broke -static-libasan
  2012-12-05  0:01 [Bug sanitizer/55599] New: switch from mach_override to mac interpose function support in libasan broke -static-libasan howarth at nitro dot med.uc.edu
                   ` (5 preceding siblings ...)
  2012-12-05  6:11 ` kcc at gcc dot gnu.org
@ 2012-12-08 19:06 ` howarth at nitro dot med.uc.edu
  6 siblings, 0 replies; 8+ messages in thread
From: howarth at nitro dot med.uc.edu @ 2012-12-08 19:06 UTC (permalink / raw)
  To: gcc-bugs


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55599

Jack Howarth <howarth at nitro dot med.uc.edu> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|                            |FIXED

--- Comment #7 from Jack Howarth <howarth at nitro dot med.uc.edu> 2012-12-08 19:06:24 UTC ---
"Fixed' with...

r194257 | kcc | 2012-12-06 09:49:44 -0500 (Thu, 06 Dec 2012) | 1 line

Fix PR55599/sanitizer by disabling static libasan on darwin


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2012-12-08 19:06 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-12-05  0:01 [Bug sanitizer/55599] New: switch from mach_override to mac interpose function support in libasan broke -static-libasan howarth at nitro dot med.uc.edu
2012-12-05  0:07 ` [Bug sanitizer/55599] " howarth at nitro dot med.uc.edu
2012-12-05  1:07 ` glider at google dot com
2012-12-05  3:47 ` howarth at nitro dot med.uc.edu
2012-12-05  4:01 ` kcc at gcc dot gnu.org
2012-12-05  4:51 ` glider at google dot com
2012-12-05  6:11 ` kcc at gcc dot gnu.org
2012-12-08 19:06 ` howarth at nitro dot med.uc.edu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).