diff mbox series

[ld] Document purpose of each ld statement lists

Message ID CAKnkMGsxcXY_dKqDDXmdiHhPKLPnawVMb1zOzor9bsz_VC1B9A@mail.gmail.com
State New
Headers show
Series [ld] Document purpose of each ld statement lists | expand

Commit Message

Thomas Preudhomme Nov. 28, 2018, 11:09 a.m. UTC
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  <thomas.preudhomme@linaro.org>

    * 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

Comments

Nick Clifton Nov. 29, 2018, 1:10 p.m. UTC | #1
Hi Thomas,

> *** ld/ChangeLog ***

> 

> 2018-11-28  Thomas Preud'homme  <thomas.preudhomme@linaro.org>

> 

>     * 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.


Approved - please apply.

Cheers
  Nick
diff mbox series

Patch

From a2819e4db15af50f379cb269e7265c2f58bd9323 Mon Sep 17 00:00:00 2001
From: Thomas Preud'homme <thomas.preudhomme@linaro.org>
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  <thomas.preudhomme@linaro.org>

	* 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