From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-oi1-x229.google.com (mail-oi1-x229.google.com [IPv6:2607:f8b0:4864:20::229]) by sourceware.org (Postfix) with ESMTPS id D0C9F3857B93 for ; Wed, 27 Sep 2023 11:59:52 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org D0C9F3857B93 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=linaro.org Received: by mail-oi1-x229.google.com with SMTP id 5614622812f47-3aec067556dso1066749b6e.2 for ; Wed, 27 Sep 2023 04:59:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1695815992; x=1696420792; darn=sourceware.org; h=content-transfer-encoding:in-reply-to:organization:from :content-language:references:to:subject:user-agent:mime-version:date :message-id:from:to:cc:subject:date:message-id:reply-to; bh=bEg98KKtdU2BTpqqF1kVFeYR4JK/MXs4hvg6xEgKODw=; b=zGLN5udSN8SwUu4XkzHOMJo+7jrc1mpyMB+LQuANN1gJ74f6RHYxYOfvQz+ZQY6ngD ifAi5lJSzO7k+6m7ESn7YuRkXlYklaEJFEaKapI1FgBsoVVeQNTUzaFIebOvj4K1kZON WBjk+XNr0wX4sg/3lDHFKUO8goDZVrfLl5n0zyKCD8nlOpjo2HWlSQ6DatiN1MJumBS7 hrjB2J1VPP8wPecgb4LfIDIIcHLi8Ll0pSWjll98MrSgkrVYLA8oMOWX0AGR4b/zI7Q3 ykWJ0ftFQP2wYtgg6wuJb6NWi9ywP/hSp4nMGke0Tuyrzxeg+QCplrhHod5Np9QNoFPj jXtA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695815992; x=1696420792; h=content-transfer-encoding:in-reply-to:organization:from :content-language:references:to:subject:user-agent:mime-version:date :message-id:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=bEg98KKtdU2BTpqqF1kVFeYR4JK/MXs4hvg6xEgKODw=; b=fizihB26TSZqlD7XWipx55gPf8kk5JVXvVMz1ncleC2DAb4AsANWw7/N6q5ThoAQWI bZBD4LNdaRqXD6mSc4Mu9sCkvSVtOexT9B8atyKzXBTTlPQPJNR7AVDfrx8Ickm/b+sw hbOrejxZpqD7KYD4YlD4BcBt2wDgu6oNzbl6/1oqi4DkLE+E0k9jeFFr9/WBWfTgXR7f CIJ+KIaTAgEVQdJ8ZELBVzvvgMWNEShVYRBJxLvy0cy/Dly9RIDiZX9+7/DnVgXSKIxH HPbfthlYL10CQ5T4HuxxJFNXd3A/JUwCv4k4zDM7EpeYjfG0bbAXDdjbRN+DadEUHesB ThXw== X-Gm-Message-State: AOJu0Yy/fGnutE1zbs7885lyB1uvx2JD4uzxc6Rq0Gbjwx5homQwIYO5 DijbKES5V2M7z3pGb/YCnnCwiw== X-Google-Smtp-Source: AGHT+IFFZSq4g9PM6+sEpK531KBSLJpOKetANglpiakDUn7pTMUOHC+VNnD0TZZSzuCu1X4G4bv9IA== X-Received: by 2002:a05:6808:101:b0:3ae:5c36:99b2 with SMTP id b1-20020a056808010100b003ae5c3699b2mr1835772oie.55.1695815992048; Wed, 27 Sep 2023 04:59:52 -0700 (PDT) Received: from ?IPV6:2804:1b3:a7c1:6eb0:212a:127a:20f3:c990? ([2804:1b3:a7c1:6eb0:212a:127a:20f3:c990]) by smtp.gmail.com with ESMTPSA id r3-20020aa78443000000b00693390caf39sm1013829pfn.113.2023.09.27.04.59.50 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 27 Sep 2023 04:59:51 -0700 (PDT) Message-ID: Date: Wed, 27 Sep 2023 08:59:48 -0300 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: need help about __stack_chk_guard To: =?UTF-8?B?6ZmI6YeR5L2z?= , "libc-help@sourceware.org" References: <436d1f6d.210bb.18ac9d41133.Coremail.chenjinjia_cn@163.com> Content-Language: en-US From: Adhemerval Zanella Netto Organization: Linaro In-Reply-To: <436d1f6d.210bb.18ac9d41133.Coremail.chenjinjia_cn@163.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-3.7 required=5.0 tests=BAYES_00,BODY_8BITS,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On 24/09/23 21:53, 陈金佳 via Libc-help wrote: > hello, i am a developer from china and i have encountered a tricky problem in the current development process. > I need to compile a dynamic library, but i don't want to use symbols with "@GLIBC in the dynamic library, because it needs to be used in different glibc runtime environments. Therefore, during the compilation and linking process, I used the -Wl,--wrap compilation option to change the glibc symbols used to __wrap_xxxx. However, this method only works for functions. Because i must use "-fstack-protector-strong",the compiled dynamic library will add "__stack_chk_guard" symbol, which is an OBJECT and cannot be replaced. I hope to get some help from you. > 1. Is there a way to replace "__stack_chk_guard" or remove "@GLIBC_2.4" from "__stack_chk_guard@GLIBC_2.4"? > 2.If there is no way to replace it, is "__stack_chk_guard" only avaliable in the GLIBC2.4 version within visible time? > > thank you! Afaik --wrap ld option works for any symbol: $ cat > lib.c < version.script < main.c < extern int foo; int __wrap_foo = 24; int main (int argc, char *argv[]) { printf ("foo=%d\n", foo); } EOF $ gcc -Wall main.c -o main -Wl,-rpath,`pwd` lib.so && ./main foo=42 $ gcc -Wall main.c -o main -Wl,-rpath,`pwd` lib.so -Wl,--wrap=foo && ./main foo=24