From patchwork Wed Nov 28 11:09:23 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Preudhomme X-Patchwork-Id: 152250 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp946996ljp; Wed, 28 Nov 2018 03:09:53 -0800 (PST) X-Google-Smtp-Source: AFSGD/XkraCV02O+b17t+N70A/JrvHXi/shkqFTDh1uNKNVXnveR7gZe902elAhAI8giOu3Puvtl X-Received: by 2002:a17:902:bc43:: with SMTP id t3mr29243774plz.124.1543403393456; Wed, 28 Nov 2018 03:09:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543403393; cv=none; d=google.com; s=arc-20160816; b=GUDWHqZmVBggee7/Jtabbd7nJKe/r+XJnxwc8vsA3bqU0xjt/v1c5DiWNztWuCq7AO tIh7FiYsAKYt1CQhYJJl2MORKa8eGglCmmSyTryCGduffaryr7rxkYdJvcAm0JDU9win YZwkmt9wDwF/ShtwsnUntl/XsHIM4n30Wbso2JAFUDYTgbjdLxG3j1mmsy83kJuwdC9P 8pDuQnl5XYCsymU8yg8tOJYF4cpWG4G1RaHKwcUFklVysnOi2Wxdmxex/q8SLCGAMd8B 64446ano0PKuXjZD9m0To7IFRrktNX8Qqr3l0wxgjsZlsdenlpo7oWDVF9jjKAhqnPbH RYxA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=to:subject:message-id:date:from:mime-version:dkim-signature :delivered-to:sender:list-help:list-post:list-archive:list-subscribe :list-unsubscribe:list-id:precedence:mailing-list:dkim-signature :domainkey-signature; bh=Mi4LMGy9+w/feVjVC0b46Sk4WBVZxOCMp1WjJ9VS8kE=; b=WTJwc3VTXOdYwfFT+dawLJnl4WMgobgCO7fcuqdNR/PwCRJZdZiD3AXlz70MIdfciG 0jTC+dUKNIO3biqTfJEQs5+TlGglXGMcxNhOchHygERtIMfRJiRXoGPB0lyQOwO/2JDm UrGp09gXCLNjJIJgD9SQhezUMSUmGaVs//p+ZNBMuPmVPbdc5Rhazh2btlGjNhKzN98l pGYgbxvWN6PjHEtGJaHK+FaDE4/a11Q/g4pxH71SB8wUZqo/qqQhtPzCFqPfiYg2ZQkM uCkNz9RNZ8znGEATRJObQmzESaCQ4bZYMeQ+8phWWFee8XfnwP3elbJ43vwNG/cedmcW y7tw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=YKw1BOen; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=R8H6CEfR; spf=pass (google.com: domain of binutils-return-104298-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom="binutils-return-104298-patch=linaro.org@sourceware.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id d10si6810896pgf.136.2018.11.28.03.09.53 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 28 Nov 2018 03:09:53 -0800 (PST) Received-SPF: pass (google.com: domain of binutils-return-104298-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Authentication-Results: mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=YKw1BOen; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=R8H6CEfR; spf=pass (google.com: domain of binutils-return-104298-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom="binutils-return-104298-patch=linaro.org@sourceware.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:mime-version:from:date:message-id:subject:to :content-type; q=dns; s=default; b=iET42MiGvqHDuTST8F7/UqZSOZ2JZ SeTq4z1xigXBcRliu8A4cMNbXWiBxNyAqOxfFl9vmrNl2PlvuxDeQzMRQWvxgrl6 zjoFeTrqJa0eAmV44ttw3x6tSJOU5/hAEo9nIOP0NIZHNiws+inE0wM/nSOEqVM6 qlXC45pWJjHKLg= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:mime-version:from:date:message-id:subject:to :content-type; s=default; bh=mil2kX/soyl2SGnGAs7wKwhReyk=; b=YKw 1BOenMdopBIUzcP4OvLw6s2wFxzrUeJHY4IaNxqQUFD/46XKjp78QeoDrNuFdFql XNZYDKNG72DmrhhJWrRC76sM4gAaH5+hHMIVjFXzJKYRCp+Wx+VIFZFoGOpQ8Jao SXBfUD8yG9aMHg8Mb7Z5B52ATwVRAv9Sjf5qcKjk= Received: (qmail 3750 invoked by alias); 28 Nov 2018 11:09:40 -0000 Mailing-List: contact binutils-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: binutils-owner@sourceware.org Delivered-To: mailing list binutils@sourceware.org Received: (qmail 3636 invoked by uid 89); 28 Nov 2018 11:09:39 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-23.4 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SEM_URI, SEM_URIRED, SPF_PASS autolearn=ham version=3.3.2 spammy=redirect, wanders, skips, HX-Envelope-From:sk:thomas. X-HELO: mail-it1-f174.google.com Received: from mail-it1-f174.google.com (HELO mail-it1-f174.google.com) (209.85.166.174) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 28 Nov 2018 11:09:35 +0000 Received: by mail-it1-f174.google.com with SMTP id h193so3528337ita.5 for ; Wed, 28 Nov 2018 03:09:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:from:date:message-id:subject:to; bh=u12fcNPM6TyGzPrRWABAoe2dzNVW9PIf7a4MbSU4Zkg=; b=R8H6CEfRBBLVuxWbyX9/oOulEKhV3vTVag8PvJbw7ZYNgkbux7uWFgwMfu2k3a7jyj 4BAWVpfvY5Pr83ewyN+bDvV4mVsHWB3K8Pc9rBmv9siPBYvJ7sfW40OdMbi8ir7pQbPj DNtH1c1Dh4dGEBPC0xFT8gm6OEC6IjUmtsk+o= MIME-Version: 1.0 From: Thomas Preudhomme Date: Wed, 28 Nov 2018 11:09:23 +0000 Message-ID: Subject: [PATCH, ld] Document purpose of each ld statement lists To: Nick Clifton , Alan Modra , binutils@sourceware.org X-IsSubscribed: yes Hi, When discovering the statement lists via their header variable statement_list, file_chain and input_file_chain it can be confusing to figure out what they are for. They can point to the same initial statement and the relation between the next field they use is not obvious from the name. This commit adds comment for each of those statement list header to explain what they are for and what next field they use. It also rewrite the comment for the next fields to simply redirect the reader to the list header to avoid duplication of documentation. ChangeLog entry is as follows: *** ld/ChangeLog *** 2018-11-28 Thomas Preud'homme * ldlang.c (statement_list): Document purpose and what next field it uses. (file_chain): Likewise. (input_file_chain): Likewise. * ldlang.h (lang_statement_header_type): Document statement list header the next pointer correspond to. (lang_statement_header_type): Replace comment for next and next_real_file field to refer the reader to their corresponding statement list header. Testing: Builds successfully. Is this ok for master? Best regards, Thomas >From a2819e4db15af50f379cb269e7265c2f58bd9323 Mon Sep 17 00:00:00 2001 From: Thomas Preud'homme Date: Wed, 28 Nov 2018 10:52:19 +0000 Subject: [PATCH] [PATCH, ld] Document purpose of each ld statement lists When discovering the statement lists via their header variable statement_list, file_chain and input_file_chain it can be confusing to figure out what they are for. They can point to the same initial statement and the relation between the next field they use is not obvious from the name. This commit adds comment for each of those statement list header to explain what they are for and what next field they use. It also rewrite the comment for the next fields to simply redirect the reader to the list header to avoid duplication of documentation. ChangeLog entry is as follows: *** ld/ChangeLog *** 2018-11-28 Thomas Preud'homme * ldlang.c (statement_list): Document purpose and what next field it uses. (file_chain): Likewise. (input_file_chain): Likewise. * ldlang.h (lang_statement_header_type): Document statement list header the next pointer correspond to. (lang_statement_header_type): Replace comment for next and next_real_file field to refer the reader to their corresponding statement list header. Testing: Builds successfully. Is this ok for master? Best regards, Thomas --- ld/ldlang.c | 16 ++++++++++++++++ ld/ldlang.h | 10 +++------- 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/ld/ldlang.c b/ld/ldlang.c index e525396668..9826479b56 100644 --- a/ld/ldlang.c +++ b/ld/ldlang.c @@ -67,6 +67,12 @@ static bfd_boolean map_option_f; static bfd_vma print_dot; static lang_input_statement_type *first_file; static const char *current_target; +/* Header for list of statements corresponding to any files involved in the + link, either specified from the command-line or added implicitely (eg. + archive member used to resolved undefined symbol, wildcard statement from + linker script, etc.). Next pointer is in next field of a + lang_statement_header_type (reached via header field in a + lang_statement_union). */ static lang_statement_list_type statement_list; static lang_statement_list_type *stat_save[10]; static lang_statement_list_type **stat_save_ptr = &stat_save[0]; @@ -97,7 +103,17 @@ const char *output_target; lang_output_section_statement_type *abs_output_section; lang_statement_list_type lang_output_section_statement; lang_statement_list_type *stat_ptr = &statement_list; +/* Header for list of statements corresponding to files used in the final + executable. This can be either object file specified on the command-line + or library member resolving an undefined reference. Next pointer is in next + field of a lang_input_statement_type (reached via input_statement field in a + lang_statement_union). */ lang_statement_list_type file_chain = { NULL, NULL }; +/* Header for list of statements corresponding to files specified on the + command-line for linking. It thus contains real object files and archive + but not archive members. Next pointer is in next_real_file field of a + lang_input_statement_type statement (reached via input_statement field in a + lang_statement_union). */ lang_statement_list_type input_file_chain; struct bfd_sym_chain entry_symbol = { NULL, NULL }; const char *entry_section = ".text"; diff --git a/ld/ldlang.h b/ld/ldlang.h index dfac0b1b68..325bbbb524 100644 --- a/ld/ldlang.h +++ b/ld/ldlang.h @@ -88,6 +88,7 @@ enum statement_enum typedef struct lang_statement_header_struct { + /* Next pointer for statement_list statement list. */ union lang_statement_union *next; enum statement_enum type; } lang_statement_header_type; @@ -306,15 +307,10 @@ typedef struct lang_input_statement_struct struct flag_info *section_flag_list; - /* Point to the next file - whatever it is, wanders up and down - archive elements. If this input_statement is for an archive, it - won't be on file_chain (which uses this list pointer), but if - any elements have been extracted from the archive, it will point - to the input_statement for the last such element. */ + /* Next pointer for file_chain statement list. */ union lang_statement_union *next; - /* Point to the next file, but skips archive contents. Used by - input_file_chain. */ + /* Next pointer for input_file_chain statement list. */ union lang_statement_union *next_real_file; const char *target; -- 2.19.1