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]

increasing ld NOP to 4 bytes


Meant to copy this to binutils list as well...

Hi Nick,
  How do you feel about increasing the ld NOP size used in
bfd_fill_link_order to four bytes?  There are quite a few targets that
need a four byte NOP, and there's only one (ia64) which needs a larger
size NOP.  I suppose fixing this properly would require changing the
ld grammar to accept a string of hex digits for a fill value, but I
haven't looked at what is required for that to work.

bfd/ChangeLog
	* linker.c (default_fill_link_order): Handle four byte fill value.
ld/ChangeLog
	* ld.texinfo: Document that fill values now use the four least
	significant bytes.
	* emulparams/elf32fr30.sh (NOP): Update.
	* emulparams/elf32mcore.sh: Likewise.
	* emulparams/elf64_s390.sh: Likewise.
	* emulparams/elf_i386.sh: Likewise.
	* emulparams/elf_i386_be.sh: Likewise.
	* emulparams/elf_i386_chaos.sh: Likewise.
	* emulparams/elf_i386_ldso.sh: Likewise.
	* emulparams/elf_s390.sh: Likewise.
	* emulparams/elf_x86_64.sh: Likewise.
	* emulparams/i386moss.sh: Likewise.
	* emulparams/i386nw.sh: Likewise.
	* emulparams/m68kelf.sh: Likewise.
	* scripttempl/elf.sc: Update NOP comment.
	* scripttempl/elfi370.sc: Likewise.
	* scripttempl/elfm68hc11.sc: Likewise.
	* scripttempl/elfm68hc12.sc: Likewise.
	* scripttempl/nw.sc: Likewise.

Alan

Index: bfd/linker.c
===================================================================
RCS file: /cvs/src/src/bfd/linker.c,v
retrieving revision 1.11
diff -u -p -r1.11 linker.c
--- linker.c	2001/08/02 23:05:54	1.11
+++ linker.c	2001/08/17 00:47:51
@@ -2655,28 +2655,35 @@ default_fill_link_order (abfd, info, sec
      struct bfd_link_order *link_order;
 {
   size_t size;
-  char *space;
+  unsigned char *space;
   size_t i;
-  int fill;
+  unsigned int fill;
+  file_ptr loc;
   boolean result;
 
   BFD_ASSERT ((sec->flags & SEC_HAS_CONTENTS) != 0);
 
   size = (size_t) link_order->size;
-  space = (char *) bfd_malloc (size);
-  if (space == NULL && size != 0)
+  if (size == 0)
+    return true;
+
+  space = (unsigned char *) bfd_malloc (size);
+  if (space == NULL)
     return false;
 
   fill = link_order->u.fill.value;
-  for (i = 0; i < size; i += 2)
+  for (i = 0; i < size; i += 4)
+    space[i] = fill >> 24;
+  for (i = 1; i < size; i += 4)
+    space[i] = fill >> 16;
+  for (i = 2; i < size; i += 4)
     space[i] = fill >> 8;
-  for (i = 1; i < size; i += 2)
+  for (i = 3; i < size; i += 4)
     space[i] = fill;
-  result = bfd_set_section_contents (abfd, sec, space,
-				     (file_ptr)
-                                     (link_order->offset *
-                                      bfd_octets_per_byte (abfd)),
-				     link_order->size);
+
+  loc = (file_ptr) (link_order->offset * bfd_octets_per_byte (abfd));
+  result = bfd_set_section_contents (abfd, sec, space, loc, link_order->size);
+
   free (space);
   return result;
 }
Index: ld/ld.texinfo
===================================================================
RCS file: /cvs/src/src/ld/ld.texinfo,v
retrieving revision 1.45
diff -u -p -r1.45 ld.texinfo
--- ld.texinfo	2001/08/12 07:59:28	1.45
+++ ld.texinfo	2001/08/17 00:48:36
@@ -2781,16 +2781,16 @@ You may use the @code{FILL} command to s
 current section.  It is followed by an expression in parentheses.  Any
 otherwise unspecified regions of memory within the section (for example,
 gaps left due to the required alignment of input sections) are filled
-with the two least significant bytes of the expression, repeated as
+with the four least significant bytes of the expression, repeated as
 necessary.  A @code{FILL} statement covers memory locations after the
 point at which it occurs in the section definition; by including more
 than one @code{FILL} statement, you can have different fill patterns in
 different parts of an output section.
 
 This example shows how to fill unspecified regions of memory with the
-value @samp{0x9090}:
+value @samp{0x90}:
 @smallexample
-FILL(0x9090)
+FILL(0x90909090)
 @end smallexample
 
 The @code{FILL} command is similar to the @samp{=@var{fillexp}} output
@@ -3076,7 +3076,7 @@ You can set the fill pattern for an enti
 @samp{=@var{fillexp}}.  @var{fillexp} is an expression
 (@pxref{Expressions}).  Any otherwise unspecified regions of memory
 within the output section (for example, gaps left due to the required
-alignment of input sections) will be filled with the two least
+alignment of input sections) will be filled with the four least
 significant bytes of the value, repeated as necessary.
 
 You can also change the fill value with a @code{FILL} command in the
@@ -3085,7 +3085,7 @@ output section commands; see @ref{Output
 Here is a simple example:
 @smallexample
 @group
-SECTIONS @{ .text : @{ *(.text) @} =0x9090 @}
+SECTIONS @{ .text : @{ *(.text) @} =0x90909090 @}
 @end group
 @end smallexample
 
@@ -3728,7 +3728,7 @@ SECTIONS
       file2(.text)
       . += 1000;
       file3(.text)
-    @} = 0x1234;
+    @} = 0x12345678;
 @}
 @end smallexample
 @noindent
@@ -3736,7 +3736,7 @@ In the previous example, the @samp{.text
 located at the beginning of the output section @samp{output}.  It is
 followed by a 1000 byte gap.  Then the @samp{.text} section from
 @file{file2} appears, also with a 1000 byte gap following before the
-@samp{.text} section from @file{file3}.  The notation @samp{= 0x1234}
+@samp{.text} section from @file{file3}.  The notation @samp{= 0x12345678}
 specifies what data to write in the gaps (@pxref{Output Section Fill}).
 
 @cindex dot inside sections
Index: ld/emulparams/elf32fr30.sh
===================================================================
RCS file: /cvs/src/src/ld/emulparams/elf32fr30.sh,v
retrieving revision 1.1.1.1
diff -u -p -r1.1.1.1 elf32fr30.sh
--- elf32fr30.sh	1999/05/03 07:29:07	1.1.1.1
+++ elf32fr30.sh	2001/08/17 00:48:36
@@ -6,5 +6,5 @@ ARCH=fr30
 MAXPAGESIZE=256
 ENTRY=_start
 EMBEDDED=yes
-NOP=0x9fa0
+NOP=0x9fa09fa0
 OTHER_RELOCATING_SECTIONS='PROVIDE (__stack = 0x200000);'
Index: ld/emulparams/elf32mcore.sh
===================================================================
RCS file: /cvs/src/src/ld/emulparams/elf32mcore.sh,v
retrieving revision 1.9
diff -u -p -r1.9 elf32mcore.sh
--- elf32mcore.sh	2000/07/20 03:25:10	1.9
+++ elf32mcore.sh	2001/08/17 00:48:36
@@ -19,7 +19,7 @@ EMBEDDED=yes
 # explicitly set first, and since the NOP code is only used as a
 # fill value between independantly viable peices of code, it should
 # not matter.
-NOP=0x0e0e
+NOP=0x0e0e0e0e
 
 OTHER_BSS_SYMBOLS="__bss_start__ = . ;"
 OTHER_BSS_END_SYMBOLS="__bss_end__ = . ;"
Index: ld/emulparams/elf64_s390.sh
===================================================================
RCS file: /cvs/src/src/ld/emulparams/elf64_s390.sh,v
retrieving revision 1.1
diff -u -p -r1.1 elf64_s390.sh
--- elf64_s390.sh	2001/02/10 00:55:50	1.1
+++ elf64_s390.sh	2001/08/17 00:48:36
@@ -6,6 +6,6 @@ MAXPAGESIZE=0x1000
 NONPAGED_TEXT_START_ADDR=0x80000000
 ARCH="s390:esame"
 MACHINE=
-NOP=0x0707
+NOP=0x07070707
 TEMPLATE_NAME=elf32
 GENERATE_SHLIB_SCRIPT=yes 
Index: ld/emulparams/elf_i386.sh
===================================================================
RCS file: /cvs/src/src/ld/emulparams/elf_i386.sh,v
retrieving revision 1.1.1.1
diff -u -p -r1.1.1.1 elf_i386.sh
--- elf_i386.sh	1999/05/03 07:29:07	1.1.1.1
+++ elf_i386.sh	2001/08/17 00:48:36
@@ -5,6 +5,6 @@ MAXPAGESIZE=0x1000
 NONPAGED_TEXT_START_ADDR=0x08048000
 ARCH=i386
 MACHINE=
-NOP=0x9090
+NOP=0x90909090
 TEMPLATE_NAME=elf32
 GENERATE_SHLIB_SCRIPT=yes
Index: ld/emulparams/elf_i386_be.sh
===================================================================
RCS file: /cvs/src/src/ld/emulparams/elf_i386_be.sh,v
retrieving revision 1.1.1.1
diff -u -p -r1.1.1.1 elf_i386_be.sh
--- elf_i386_be.sh	1999/05/03 07:29:07	1.1.1.1
+++ elf_i386_be.sh	2001/08/17 00:48:36
@@ -6,6 +6,6 @@ NONPAGED_TEXT_START_ADDR=0x80000000
 MAXPAGESIZE=0x1000
 ARCH=i386
 MACHINE=
-NOP=0x9090
+NOP=0x90909090
 TEMPLATE_NAME=elf32
 GENERATE_SHLIB_SCRIPT=yes
Index: ld/emulparams/elf_i386_chaos.sh
===================================================================
RCS file: /cvs/src/src/ld/emulparams/elf_i386_chaos.sh,v
retrieving revision 1.1
diff -u -p -r1.1 elf_i386_chaos.sh
--- elf_i386_chaos.sh	2000/11/02 23:03:24	1.1
+++ elf_i386_chaos.sh	2001/08/17 00:48:36
@@ -5,6 +5,6 @@ MAXPAGESIZE=0x1000
 NONPAGED_TEXT_START_ADDR=0x40000000
 ARCH=i386
 MACHINE=
-NOP=0x9090
+NOP=0x90909090
 TEMPLATE_NAME=elf32
 GENERATE_SHLIB_SCRIPT=yes
Index: ld/emulparams/elf_i386_ldso.sh
===================================================================
RCS file: /cvs/src/src/ld/emulparams/elf_i386_ldso.sh,v
retrieving revision 1.1
diff -u -p -r1.1 elf_i386_ldso.sh
--- elf_i386_ldso.sh	2001/05/22 14:00:18	1.1
+++ elf_i386_ldso.sh	2001/08/17 00:48:36
@@ -5,7 +5,7 @@ MAXPAGESIZE=0x1000
 NONPAGED_TEXT_START_ADDR=0x08048000
 ARCH=i386
 MACHINE=
-NOP=0x9090
+NOP=0x90909090
 TEMPLATE_NAME=elf32
 GENERATE_SHLIB_SCRIPT=yes
 ELF_INTERPRETER_NAME=\"/usr/lib/ld.so.1\"
Index: ld/emulparams/elf_s390.sh
===================================================================
RCS file: /cvs/src/src/ld/emulparams/elf_s390.sh,v
retrieving revision 1.1
diff -u -p -r1.1 elf_s390.sh
--- elf_s390.sh	2001/02/10 00:55:50	1.1
+++ elf_s390.sh	2001/08/17 00:48:36
@@ -5,6 +5,6 @@ MAXPAGESIZE=0x1000
 NONPAGED_TEXT_START_ADDR=0x00400000
 ARCH=s390
 MACHINE=
-NOP=0x0707
+NOP=0x07070707
 TEMPLATE_NAME=elf32
 GENERATE_SHLIB_SCRIPT=yes 
Index: ld/emulparams/elf_x86_64.sh
===================================================================
RCS file: /cvs/src/src/ld/emulparams/elf_x86_64.sh,v
retrieving revision 1.3
diff -u -p -r1.3 elf_x86_64.sh
--- elf_x86_64.sh	2001/06/07 11:18:15	1.3
+++ elf_x86_64.sh	2001/08/17 00:48:36
@@ -6,6 +6,6 @@ MAXPAGESIZE=0x100000
 NONPAGED_TEXT_START_ADDR=0x400000
 ARCH=i386
 MACHINE=
-NOP=0x9090
+NOP=0x90909090
 TEMPLATE_NAME=elf32
 GENERATE_SHLIB_SCRIPT=yes
Index: ld/emulparams/i386moss.sh
===================================================================
RCS file: /cvs/src/src/ld/emulparams/i386moss.sh,v
retrieving revision 1.1.1.1
diff -u -p -r1.1.1.1 i386moss.sh
--- i386moss.sh	1999/05/03 07:29:07	1.1.1.1
+++ i386moss.sh	2001/08/17 00:48:36
@@ -5,6 +5,6 @@ MAXPAGESIZE=0x1000
 NONPAGED_TEXT_START_ADDR=0x00002000
 ARCH=i386
 MACHINE=
-NOP=0x9090
+NOP=0x90909090
 TEMPLATE_NAME=elf32
 GENERATE_SHLIB_SCRIPT=yes
Index: ld/emulparams/i386nw.sh
===================================================================
RCS file: /cvs/src/src/ld/emulparams/i386nw.sh,v
retrieving revision 1.1.1.1
diff -u -p -r1.1.1.1 i386nw.sh
--- i386nw.sh	1999/05/03 07:29:07	1.1.1.1
+++ i386nw.sh	2001/08/17 00:48:36
@@ -4,6 +4,6 @@ TEXT_START_ADDR=0x08000000
 MAXPAGESIZE=0x1000
 NONPAGED_TEXT_START_ADDR=0x08000000
 ARCH=i386
-NOP=0x9090
+NOP=0x90909090
 TEMPLATE_NAME=elf32
 GENERATE_SHLIB_SCRIPT=yes
Index: ld/emulparams/m68kelf.sh
===================================================================
RCS file: /cvs/src/src/ld/emulparams/m68kelf.sh,v
retrieving revision 1.2
diff -u -p -r1.2 m68kelf.sh
--- m68kelf.sh	2000/09/15 18:52:14	1.2
+++ m68kelf.sh	2001/08/17 00:48:36
@@ -5,7 +5,7 @@ MAXPAGESIZE=0x2000
 NONPAGED_TEXT_START_ADDR=${TEXT_START_ADDR}
 ARCH=m68k
 MACHINE=
-NOP=0x4e75
+NOP=0x4e754e75
 TEMPLATE_NAME=elf32
 EXTRA_EM_FILE=m68kelf
 GENERATE_SHLIB_SCRIPT=yes
Index: ld/scripttempl/elf.sc
===================================================================
RCS file: /cvs/src/src/ld/scripttempl/elf.sc,v
retrieving revision 1.20
diff -u -p -r1.20 elf.sc
--- elf.sc	2001/08/12 20:19:48	1.20
+++ elf.sc	2001/08/17 00:48:37
@@ -1,6 +1,6 @@
 #
 # Unusual variables checked by this code:
-#	NOP - two byte opcode for no-op (defaults to 0)
+#	NOP - four byte opcode for no-op (defaults to 0)
 #	DATA_ADDR - if end-of-text-plus-one-page isn't right for data start
 #	INITIAL_READONLY_SECTIONS - at start of text segment
 #	OTHER_READONLY_SECTIONS - other than .text .init .rodata ...
Index: ld/scripttempl/elfi370.sc
===================================================================
RCS file: /cvs/src/src/ld/scripttempl/elfi370.sc,v
retrieving revision 1.2
diff -u -p -r1.2 elfi370.sc
--- elfi370.sc	2000/09/02 20:43:22	1.2
+++ elfi370.sc	2001/08/17 00:48:37
@@ -2,7 +2,7 @@
 # This is just a raw copy of elfppc.sc and has not been otherwise modified
 #
 # Unusual variables checked by this code:
-#	NOP - two byte opcode for no-op (defaults to 0)
+#	NOP - four byte opcode for no-op (defaults to 0)
 #	DATA_ADDR - if end-of-text-plus-one-page isn't right for data start
 #	OTHER_READONLY_SECTIONS - other than .text .init .rodata ...
 #		(e.g., .PARISC.milli)
Index: ld/scripttempl/elfm68hc11.sc
===================================================================
RCS file: /cvs/src/src/ld/scripttempl/elfm68hc11.sc,v
retrieving revision 1.5
diff -u -p -r1.5 elfm68hc11.sc
--- elfm68hc11.sc	2001/08/12 20:19:48	1.5
+++ elfm68hc11.sc	2001/08/17 00:48:37
@@ -1,6 +1,6 @@
 #
 # Unusual variables checked by this code:
-#	NOP - two byte opcode for no-op (defaults to 0)
+#	NOP - four byte opcode for no-op (defaults to 0)
 #	DATA_ADDR - if end-of-text-plus-one-page isn't right for data start
 #	OTHER_READWRITE_SECTIONS - other than .data .bss .ctors .sdata ...
 #		(e.g., .PARISC.global)
Index: ld/scripttempl/elfm68hc12.sc
===================================================================
RCS file: /cvs/src/src/ld/scripttempl/elfm68hc12.sc,v
retrieving revision 1.5
diff -u -p -r1.5 elfm68hc12.sc
--- elfm68hc12.sc	2001/08/12 20:19:49	1.5
+++ elfm68hc12.sc	2001/08/17 00:48:37
@@ -1,6 +1,6 @@
 #
 # Unusual variables checked by this code:
-#	NOP - two byte opcode for no-op (defaults to 0)
+#	NOP - four byte opcode for no-op (defaults to 0)
 #	DATA_ADDR - if end-of-text-plus-one-page isn't right for data start
 #	OTHER_READWRITE_SECTIONS - other than .data .bss .ctors .sdata ...
 #		(e.g., .PARISC.global)
Index: ld/scripttempl/nw.sc
===================================================================
RCS file: /cvs/src/src/ld/scripttempl/nw.sc,v
retrieving revision 1.1.1.1
diff -u -p -r1.1.1.1 nw.sc
--- nw.sc	1999/05/03 07:29:08	1.1.1.1
+++ nw.sc	2001/08/17 00:48:37
@@ -1,6 +1,6 @@
 #
 # Unusual variables checked by this code:
-#	NOP - two byte opcode for no-op (defaults to 0)
+#	NOP - four byte opcode for no-op (defaults to 0)
 #	DATA_ADDR - if end-of-text-plus-one-page isn't right for data start
 #	OTHER_READONLY_SECTIONS - other than .text .init .ctors .rodata ...
 #		(e.g., .PARISC.milli)


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