From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-ej1-x62e.google.com (mail-ej1-x62e.google.com [IPv6:2a00:1450:4864:20::62e]) by sourceware.org (Postfix) with ESMTPS id 2D38D385840F for ; Mon, 29 Jan 2024 14:03:48 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 2D38D385840F Authentication-Results: sourceware.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=suse.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 2D38D385840F Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::62e ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1706537036; cv=none; b=Na+9BKhOYCc8yXozn/mFSN9/YD0O+uOh4X6bqj+tEQCyHetUrg7hpSbCtQszsc1XwnaVTiA5+QeMqor3CRQ9gpgISFAqfy9+8Fm92HRxOLCpfFaCwWKHRLk+eclwpdJbLu5jbviaGqGndSvRBIL1E0R7/szAsJfIYAA6kq1N3YQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1706537036; c=relaxed/simple; bh=8nNZAX5R5BssbH9MKbf/onut37pC3rcMS8UnbwftMKA=; h=DKIM-Signature:Message-ID:Date:MIME-Version:Subject:To:From; b=D9MdOutbdmF7F+3ghWZyyBjlnfWIrn7y0iWN4T5GcNSqTAmzd0h408hPoGyOAJXmYVC/LLocXZ6cd8k5M8jvKgGdwjtH7BiIOyyHLgvnRS3o7PLajQqf07RhRsD8crG7cL4Z4aNui3ZpgoOFzMUvwjjDD+3DX7NZGqhIhdaokic= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-ej1-x62e.google.com with SMTP id a640c23a62f3a-a30e445602cso792372966b.0 for ; Mon, 29 Jan 2024 06:03:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1706537027; x=1707141827; darn=sourceware.org; h=content-transfer-encoding:in-reply-to:autocrypt:from:references:cc :to:content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=ssd+M2faJnAvCNMU8JLEMpKTt4wkOAvN8k+XklHWGF4=; b=DsZE0X50JRZNJ/Tvz5eAAugu0mZ/eeMdqitd+y2F3N8/6hygq6FbVicaPFTz1tS4+g P3zkL3IoexGbZdES4JMf42pnzxM1emC+Flzn81R+FejMX+F8nwT3p0xp1TrejOp2ZTuk 87V5ygztmgNxgO0asVaEQF9Ci8SPu7Jp/lrw4OMlMwhJfih2rALeiz6+tJk60rvqh/HW kPJSrLuVAinGsHiq1flgkBNdbqXRl6eKJnWqEzt1VApiZAsJA8eOh89xjqVrwuV5yvjd 5JHHsPl1ccgbwWOE9AeuyDTxpfuem35aQx5tNCrIyENSxpltZZ13FgnPMhP9LQoaizum A8GA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706537027; x=1707141827; h=content-transfer-encoding:in-reply-to:autocrypt:from:references:cc :to:content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=ssd+M2faJnAvCNMU8JLEMpKTt4wkOAvN8k+XklHWGF4=; b=xEOJe5DJlPY3/CRfcr2S778xSWuPK42XtX/oLfvBOaglZ3Vfi/d4/tbeIQS3KFYu5g vtgR1PY0szDu8uJsx0g/pet+jElwGA6Vd8OiDZd6p5Ik9/h235RnRO42UBp2HhcjXYnH T+dCsFB3JLL51ct3QlISesjQT/R9HSGmrkoEU56tovcjTELBEcn10KSArRBHH+XjlW5f HRax1XaZ2A96ox1kxjE0/DCEbMPKojJJ22rmb0WWWiEDjtVycKhQoUMSAePCTM0Qjgxp 1dza7R3RCGI5uOca+2bDjn5koUc4PQEE1rpRd+U3JMUAe701W7D55jdRV33EXdAd9Q5I puMQ== X-Gm-Message-State: AOJu0YzjRfknoyvUDzQGBurChG3D9iHLWwImMchEIdTTd99tI3jATgtV Um23nd7E8kbjShVqMQ2nKS2+/ukvfU7uEWnKeI7jxsWt1ABZYIBZhw+SdfQPcg== X-Google-Smtp-Source: AGHT+IGtSU63nlTtdpLS+s09tMbd6hXis1wbj7sFe/2GuGivQZnfmHqUmhNcof7Q04rDhz4Vtz7FAg== X-Received: by 2002:a17:906:cf8f:b0:a30:c104:3a9c with SMTP id um15-20020a170906cf8f00b00a30c1043a9cmr7529384ejb.13.1706537026821; Mon, 29 Jan 2024 06:03:46 -0800 (PST) Received: from [10.156.60.236] (ip-037-024-206-209.um08.pools.vodafone-ip.de. [37.24.206.209]) by smtp.gmail.com with ESMTPSA id 14-20020a5d9c0e000000b007bf2dcd385bsm2098626ioe.5.2024.01.29.06.03.45 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 29 Jan 2024 06:03:45 -0800 (PST) Message-ID: Date: Mon, 29 Jan 2024 15:03:43 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v2] ld: Turn on --error-execstack/--error-rwx-segments Content-Language: en-US To: "H.J. Lu" Cc: binutils@sourceware.org References: <20240126214553.46536-1-hjl.tools@gmail.com> <29c60b5a-8594-4c4d-b97d-f1d96761a27e@suse.com> From: Jan Beulich Autocrypt: addr=jbeulich@suse.com; keydata= xsDiBFk3nEQRBADAEaSw6zC/EJkiwGPXbWtPxl2xCdSoeepS07jW8UgcHNurfHvUzogEq5xk hu507c3BarVjyWCJOylMNR98Yd8VqD9UfmX0Hb8/BrA+Hl6/DB/eqGptrf4BSRwcZQM32aZK 7Pj2XbGWIUrZrd70x1eAP9QE3P79Y2oLrsCgbZJfEwCgvz9JjGmQqQkRiTVzlZVCJYcyGGsD /0tbFCzD2h20ahe8rC1gbb3K3qk+LpBtvjBu1RY9drYk0NymiGbJWZgab6t1jM7sk2vuf0Py O9Hf9XBmK0uE9IgMaiCpc32XV9oASz6UJebwkX+zF2jG5I1BfnO9g7KlotcA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2ZY5AqjcKwAxpE75MLFkr wkkEGBECAAkFAlk3nEQCGwwACgkQoDSui/t3IH7nnwCfcJWUDUFKdCsBH/E5d+0ZnMQi+G0A nAuWpQkjM1ASeQwSHEeAWPgskBQL In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-3025.7 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_NONE,TXREP,T_SCC_BODY_TEXT_LINE 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 29.01.2024 14:03, H.J. Lu wrote: > On Sun, Jan 28, 2024 at 11:30 PM Jan Beulich wrote: >> >> On 26.01.2024 22:45, H.J. Lu wrote: >>> --- a/ld/lexsup.c >>> +++ b/ld/lexsup.c >>> @@ -1947,6 +1947,17 @@ parse_args (unsigned argc, char **argv) >>> && command_line.check_section_addresses < 0) >>> command_line.check_section_addresses = 0; >>> >>> + /* Override --no-error-execstack and --no-warn-execstack and turn on >>> + --error-execstack for --warn-execstack and --error-rwx-segments for >>> + --warn-rwx-segments if --fatal-warnings is used. */ >>> + if (config.fatal_warnings) >>> + { >>> + if (link_info.warn_execstack) >>> + link_info.error_execstack = 1; >>> + if (!link_info.no_warn_rwx_segments) >>> + link_info.warn_is_error_for_rwx_segments = 1; >>> + } >>> + >>> if (export_list) >>> { >>> struct bfd_elf_version_expr *head = export_list->head.list; >> >> If I'm not mistaken and if the comment is properly describing things, >> this placement of the addition means --no-* last on the command line >> wouldn't be honored anymore, when later arguments ought to override >> earlier ones. >> > > Before my change, we got > > [hjl@gnu-cfl-3 ld]$ touch x.s > [hjl@gnu-cfl-3 ld]$ gcc -c x.s > [hjl@gnu-cfl-3 ld]$ ld -shared -z stack-size=0x123400 --fatal-warnings > --warn-execstack --no-error-execstack x.o > ld: warning: x.o: missing .note.GNU-stack section implies executable stack > ld: NOTE: This behaviour is deprecated and will be removed in a future > version of the linker > [hjl@gnu-cfl-3 ld]$ echo $? > 1 > > The warning is misleading since --fatal-warnings IS position independent > and is always fatal for ANY warning. My patch changes it to > > [hjl@gnu-cfl-3 ld]$ ./ld-new -shared -z stack-size=0x123400 > --fatal-warnings --warn-execstack --no-error-execstack x.o > ./ld-new: error: x.o: is triggering the generation of an executable > stack because it does not have a .note.GNU-stack section > ./ld-new: failed to set dynamic section sizes: file format not recognized > [hjl@gnu-cfl-3 ld]$ > > Any other comments to my patch? Well. To me, it is ambiguous what "--fatal-warnings --warn-execstack --no-error-execstack" actually is intended to mean (and that's regardless of --fatal-warnings position on the command line). One way of interpreting is your way. The other is to say that --no-error-execstack means "no error for anything related to executable stacks", i.e. --fatal-warnings not affecting the overall result (when there are no other warnings). Jan