This is the mail archive of the binutils@sources.redhat.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]
Other format: [Raw text]

Re: target-specific way to make ld -N the default


Hi Doug,

> In the meantime there is LDEMUL_BEFORE_PARSE.
> I see the mmix port is already making an attempt at this:
> 
> static void
> elfmmix_before_parse ()
> {
>   gld${EMULATION_NAME}_before_parse ();
> 
>   /* Make sure we don't create a demand-paged executable.  Unfortunately
>      this isn't changeable with a command-line option.  It makes no
>      difference to mmo, but the sections in elf64mmix will be aligned to a
>      page in the linked file, which is non-intuitive.  If there's ever a
>      full system with shared libraries and demand paging, you will want to
>      exclude this file.  */
>   config.magic_demand_paged = false;
> }

I rather like this solution.  It lets individual targets make up their
own minds about the default without requiring the rather clumsy
definition of EMBEDDED or (shudder, grin) REALLY_EMBEDDED.  The only
problem is the lack of a way to override the default "-N" behaviour
from the command line, and solving that is easy:

Cheers
        Nick

2002-10-23  Nick Clifton  <nickc@redhat.com>

	* lexsup.c (OPTION_NO_OMAGIC): Define.
        (ld_options): Add "no-omagic" option.
        (parse_args): Parse --no-omagic.
        * ld.texinfo: Document --no-omagic.
        * NEWS: Mention new option.

Index: ld/lexsup.c
===================================================================
RCS file: /cvs/src/src/ld/lexsup.c,v
retrieving revision 1.53
diff -c -3 -p -w -r1.53 lexsup.c
*** ld/lexsup.c	8 Oct 2002 20:12:45 -0000	1.53
--- ld/lexsup.c	23 Oct 2002 13:21:45 -0000
*************** int parsing_defsym = 0;
*** 132,137 ****
--- 132,138 ----
  #define OPTION_SPARE_DYNAMIC_TAGS	(OPTION_DISCARD_NONE + 1)
  #define OPTION_NO_DEFINE_COMMON		(OPTION_SPARE_DYNAMIC_TAGS + 1)
  #define OPTION_NOSTDLIB			(OPTION_NO_DEFINE_COMMON + 1)
+ #define OPTION_NO_OMAGIC		(OPTION_NOSTDLIB + 1)
  
  /* The long options.  This structure is used for both the option
     parsing and the help text.  */
*************** static const struct ld_option ld_options
*** 217,222 ****
--- 218,225 ----
    { {"omagic", no_argument, NULL, 'N'},
        'N', NULL, N_("Do not page align data, do not make text readonly"),
        EXACTLY_TWO_DASHES },
+   { {"no-omagic", no_argument, NULL, OPTION_NO_OMAGIC},
+       '\0', NULL, N_("Page align data, make text readonly"), EXACTLY_TWO_DASHES },
    { {"output", required_argument, NULL, 'o'},
        'o', N_("FILE"), N_("Set output file name"), EXACTLY_TWO_DASHES },
    { {NULL, required_argument, NULL, '\0'},
*************** parse_args (argc, argv)
*** 744,749 ****
--- 747,758 ----
  	  config.text_read_only = false;
  	  config.magic_demand_paged = false;
  	  config.dynamic_link = false;
+ 	  break;
+ 	case OPTION_NO_OMAGIC:
+ 	  config.text_read_only = true;
+ 	  config.magic_demand_paged = true;
+ 	  /* NB/ Does not set dynamic_link to true.
+ 	     Use --call-shared or -Bdynamic for this.  */
  	  break;
  	case 'n':
  	  config.magic_demand_paged = false;

Index: ld/ld.texinfo
===================================================================
RCS file: /cvs/src/src/ld/ld.texinfo,v
retrieving revision 1.73
diff -c -3 -p -w -r1.73 ld.texinfo
*** ld/ld.texinfo	13 Aug 2002 02:27:11 -0000	1.73
--- ld/ld.texinfo	23 Oct 2002 13:21:47 -0000
*************** Turn off page alignment of sections, and
*** 660,667 ****
  @item -N
  @itemx --omagic
  Set the text and data sections to be readable and writable.  Also, do
! not page-align the data segment.  If the output format supports Unix
! style magic numbers, mark the output as @code{OMAGIC}.
  
  @kindex -o @var{output}
  @kindex --output=@var{output}
--- 660,676 ----
  @item -N
  @itemx --omagic
  Set the text and data sections to be readable and writable.  Also, do
! not page-align the data segment, and disable linking against shared
! libraries.  If the output format supports Unix style magic numbers,
! mark the output as @code{OMAGIC}.
! 
! @kindex --no-omagic
! @cindex OMAGIC
! @item --no-omagic
! This option negates most of the effects of the @option{-N} option.  It
! sets the text section to be read-only, and forces the data segment to
! be page-aligned.  Note - this option does not enable linking against
! shared libraries.  Use @option{-Bdynamic} for this.
  
  @kindex -o @var{output}
  @kindex --output=@var{output}

Index: ld/NEWS
===================================================================
RCS file: /cvs/src/src/ld/NEWS,v
retrieving revision 1.31
diff -c -3 -p -w -r1.31 NEWS
*** ld/NEWS	11 Sep 2002 14:42:45 -0000	1.31
--- ld/NEWS	23 Oct 2002 13:21:47 -0000
***************
*** 1,5 ****
--- 1,7 ----
  -*- text -*-
  
+ * Added --no-omagic to undo the effects of the -N option.
+ 
  * Support for Texas Instruments TMS320C4x and TMS320C3x series of
    DSP's contributed by Michael Hayes and Svein E. Seldal.
    


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