This is the mail archive of the binutils@sourceware.cygnus.com mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: ld -r breakage


Hi Guys,

: On Mon, 12 Jun 2000, Jakub Jelinek wrote:
: 
: > ld -r no longer preserves SEC_READONLY attribute for some sections.
: 
: I suspect it's this patch (presumably for correct -N operation)
: 
: 2000-05-22  Igor Shevlyakov  <igor@windriver.com>
: 
: 	* ldmain.c (main): When deciding if ".text" section should be
:         read-only, don't forget to reset SEC_READONLY because it
:         could be already set.
: 
: This will fix it
: 
: 2000-06-12  Alan Modra  <alan@linuxcare.com.au>
: 
: 	* ldmain.c (main): Only change .text SEC_READONLY for final link.
: 
: Index: ldmain.c
: ===================================================================
: RCS file: /cvs/src/src/ld/ldmain.c,v
: retrieving revision 1.7
: diff -u -p -r1.7 ldmain.c
: --- ldmain.c	2000/05/26 13:11:57	1.7
: +++ ldmain.c	2000/06/12 09:40:03
: @@ -349,17 +349,18 @@ main (argc, argv)
:       symbols, and possibly multiple definitions */
:  
:    /* Look for a text section and switch the readonly attribute in it.  */
: -  {
: -    asection * found = bfd_get_section_by_name (output_bfd, ".text");
: +  if (!link_info.relocateable)
: +    {
: +      asection * found = bfd_get_section_by_name (output_bfd, ".text");
:      
: -    if (found != (asection *) NULL)
: -      {
: -	if (config.text_read_only)
: -	  found->flags |= SEC_READONLY;
: -	else
: -	  found->flags &= ~SEC_READONLY;
: -      }
: -  }
: +      if (found != (asection *) NULL)
: +	{
: +	  if (config.text_read_only)
: +	    found->flags |= SEC_READONLY;
: +	  else
: +	    found->flags &= ~SEC_READONLY;
: +	}
: +    }
:  
:    if (link_info.relocateable)
:      output_bfd->flags &= ~EXEC_P;


Although this solution will probably work, it does not strike me as
being the right thing to do.  Surely the correct thing to do is to set
the config.text_read_only flag correctly, even for a partial link,
rather than ignoring it.  The real bug is probably this line from
parse_args() in lexsup.c:

	case 'r':
	  link_info.relocateable = true;
	  config.build_constructors = false;
	  config.magic_demand_paged = false;
	  config.text_read_only = false;       <=== Why ???
	  config.dynamic_link = false;
	  break;

This problem was recently reported by Tom de Lellis:

  http://sourceware.cygnus.com/ml/binutils/2000-06/msg00085.html

I plan to check in a patch that removes this line, unless anyone
objects.

Cheers
	Nick


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]