From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 20010 invoked by alias); 26 Jul 2005 11:17:20 -0000 Mailing-List: contact gcc-help-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-help-owner@gcc.gnu.org Received: (qmail 19671 invoked by uid 22791); 26 Jul 2005 11:17:16 -0000 Received: from dmghome.golubovsky.org (HELO mail.golubovsky.org) (69.177.169.61) by sourceware.org (qpsmtpd/0.30-dev) with ESMTP; Tue, 26 Jul 2005 11:17:16 +0000 Received: from [192.168.254.30] (helo=golubovsky.org) by mail.golubovsky.org with esmtp (Exim 3.33 #2) id 1DxNQy-0002sr-00; Tue, 26 Jul 2005 07:17:16 -0400 Message-ID: <42E61BBC.1070501@golubovsky.org> Date: Tue, 26 Jul 2005 11:17:00 -0000 From: Dimitry Golubovsky User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.0.0) Gecko/20020605 MIME-Version: 1.0 To: gcc@gcc.cnu.org, gcc-help@gcc.gnu.org Subject: Please help with __attribute__ weak Content-Type: text/plain; charset=KOI8-R; format=flowed Content-Transfer-Encoding: 7bit X-SW-Source: 2005-07/txt/msg00284.txt.bz2 I need to declare a symbol which is weaker in the executable than in any external static or dynamic library. In other words, the executable provides some fallback function implementation (in my example, for "write"). But if the linker or dynamic linker resolves it, the symbol definition from an external library must be used. I use: __f_write_weak_alias(int __fd, __const __ptr_t __buf, size_t __n) __attribute__((weak, alias ("write"))); /* alias declaration */ int write(int __fd, __const __ptr_t __buf, size_t __n) { printf("Abort\n"); } /* fallback implementation */ But even though "write" is resolved, calling the __f_write_weak_alias just prints "Abort" i. e. the symbol "write" was not overridden by the library definition. What is the right way to do this? Thanks for any advice. Dimitry Golubovsky Middletown, CT