public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* [GOLD][PATCH] predefined segment symbol _begin
@ 2010-02-10 23:06 Viktor Kutuzov
  2010-02-11  0:11 ` Ian Lance Taylor
  0 siblings, 1 reply; 5+ messages in thread
From: Viktor Kutuzov @ 2010-02-10 23:06 UTC (permalink / raw)
  To: Ian Lance Taylor; +Cc: binutils

[-- Attachment #1: Type: text/plain, Size: 258 bytes --]

Hello everyone,

Please find attached patch, which adds an additional predefined segment
symbol _begin.

This is used, for example, in the glibc build.

-Viktor.

* gold/defstd.cc: added a new predefined symbol _begin to the
Define_symbol_in_segment array.


[-- Attachment #2: binutils-gold-stddef_begin_symbol.patch --]
[-- Type: text/x-patch, Size: 870 bytes --]

Index: defstd.cc
===================================================================
RCS file: /cvs/src/src/gold/defstd.cc,v
retrieving revision 1.8
diff -u -p -r1.8 defstd.cc
--- defstd.cc	7 Nov 2009 02:02:29 -0000	1.8
+++ defstd.cc	10 Feb 2010 18:48:57 -0000
@@ -189,6 +189,20 @@ const Define_symbol_in_segment in_segmen
     true			// only_if_ref
   },
   {
+    "_begin",	// name
+    elfcpp::PT_LOAD,		// segment_type
+    elfcpp::PF(0),		// segment_flags_set
+    elfcpp::PF(0),		// segment_flags_clear
+    0,				// value
+    0,				// size
+    elfcpp::STT_NOTYPE,		// type
+    elfcpp::STB_GLOBAL,		// binding
+    elfcpp::STV_DEFAULT,	// visibility
+    0,				// nonvis
+    Symbol::SEGMENT_START,	// offset_from_base
+    true			// only_if_ref
+  },
+  {
     "etext",			// name
     elfcpp::PT_LOAD,		// segment_type
     elfcpp::PF_X,		// segment_flags_set

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [GOLD][PATCH] predefined segment symbol _begin
  2010-02-10 23:06 [GOLD][PATCH] predefined segment symbol _begin Viktor Kutuzov
@ 2010-02-11  0:11 ` Ian Lance Taylor
  2010-02-11  0:41   ` Viktor Kutuzov
  0 siblings, 1 reply; 5+ messages in thread
From: Ian Lance Taylor @ 2010-02-11  0:11 UTC (permalink / raw)
  To: vkutuzov; +Cc: binutils

Viktor Kutuzov <vkutuzov@accesssoftek.com> writes:

> Please find attached patch, which adds an additional predefined segment
> symbol _begin.
>
> This is used, for example, in the glibc build.

I don't see anything in the GNU linker which defines a _begin symbol.

Are you sure it isn't coming from a linker script?

Ian

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [GOLD][PATCH] predefined segment symbol _begin
  2010-02-11  0:11 ` Ian Lance Taylor
@ 2010-02-11  0:41   ` Viktor Kutuzov
  2010-02-11  1:16     ` Ian Lance Taylor
  0 siblings, 1 reply; 5+ messages in thread
From: Viktor Kutuzov @ 2010-02-11  0:41 UTC (permalink / raw)
  To: Ian Lance Taylor; +Cc: binutils

I'm not sure. I have checked the ld scripts, but I didn't find anything
related with it. I looked for the _begin definition in the ld sources
and I got the same result. It looks strange for me, but anyway.
I seen that the _end and _etext symbols were resolved during the build,
but _begin wasn't and I added this description accordingly.

-Viktor.

On Wed, 2010-02-10 at 16:11 -0800, Ian Lance Taylor wrote:
> Viktor Kutuzov <vkutuzov@accesssoftek.com> writes:
> 
> > Please find attached patch, which adds an additional predefined segment
> > symbol _begin.
> >
> > This is used, for example, in the glibc build.
> 
> I don't see anything in the GNU linker which defines a _begin symbol.
> 
> Are you sure it isn't coming from a linker script?
> 
> Ian


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [GOLD][PATCH] predefined segment symbol _begin
  2010-02-11  0:41   ` Viktor Kutuzov
@ 2010-02-11  1:16     ` Ian Lance Taylor
  2010-02-11  3:00       ` Viktor Kutuzov
  0 siblings, 1 reply; 5+ messages in thread
From: Ian Lance Taylor @ 2010-02-11  1:16 UTC (permalink / raw)
  To: vkutuzov; +Cc: binutils

Viktor Kutuzov <vkutuzov@accesssoftek.com> writes:

> I'm not sure. I have checked the ld scripts, but I didn't find anything
> related with it. I looked for the _begin definition in the ld sources
> and I got the same result. It looks strange for me, but anyway.
> I seen that the _end and _etext symbols were resolved during the build,
> but _begin wasn't and I added this description accordingly.

We're going to need to track this down.  I don't want to have gold
start defining a symbol which the GNU linker does not.  Can you send
the complete link line and error message that you get when using gold?
Also include any linker script that may be used.  Thanks.

Ian

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [GOLD][PATCH] predefined segment symbol _begin
  2010-02-11  1:16     ` Ian Lance Taylor
@ 2010-02-11  3:00       ` Viktor Kutuzov
  0 siblings, 0 replies; 5+ messages in thread
From: Viktor Kutuzov @ 2010-02-11  3:00 UTC (permalink / raw)
  To: Ian Lance Taylor; +Cc: binutils

[-- Attachment #1: Type: text/plain, Size: 1646 bytes --]

On Wed, 2010-02-10 at 17:16 -0800, Ian Lance Taylor wrote:
> Viktor Kutuzov <vkutuzov@accesssoftek.com> writes:
> 
> > I'm not sure. I have checked the ld scripts, but I didn't find anything
> > related with it. I looked for the _begin definition in the ld sources
> > and I got the same result. It looks strange for me, but anyway.
> > I seen that the _end and _etext symbols were resolved during the build,
> > but _begin wasn't and I added this description accordingly.
> 
> We're going to need to track this down.  I don't want to have gold
> start defining a symbol which the GNU linker does not.  Can you send
> the complete link line and error message that you get when using gold?
> Also include any linker script that may be used.  Thanks.

I have attached the text file with the complete link command line and
error message -- binutils-gold-glibc-link-cmd-line_and_error.txt.

You are right, the _begin symbol is coming from the linker script, but
the used ld script -- ld.so.lds -- is empty. I took one more look on the
build log and I found that the previous step should prepare an
appropriate ld script, which defines  _begin, but, really, doesn't do it
(attached binutils-gold-make-ld-script-cmd-line.txt contains the
complete cmd line). It happens because GOLD doesn't dump the linker
script on -verbose (GNU linker does), which is expected by the sed
script.

I have attached required linker script, which was generated with the gnu
linker for information (ld.so.lds-needed).

So, as result, a real problem is in another place and my patch is
incorrect. Please decline this patch. Sorry for the false alarm.

Thank you.
-Viktor.


[-- Attachment #2: binutils-gold-glibc-link-cmd-line_and_error.txt --]
[-- Type: text/plain, Size: 709 bytes --]

arm-none-linux-gnueabi-gcc   -nostdlib -nostartfiles -shared -o /opt/crosstool/build-gold/work/obj.glibc/elf/ld.so			\
		  -Wl,-z,combreloc -Wl,-z,relro -Wl,--hash-style=both -Wl,-z,defs 	\
		  /opt/crosstool/build-gold/work/obj.glibc/elf/librtld.os -Wl,--version-script=/opt/crosstool/build-gold/work/obj.glibc/ld.map		\
		  -Wl,-soname=ld-linux.so.3 -T /opt/crosstool/build-gold/work/obj.glibc/elf/ld.so.lds

/opt/crosstool/build-gold/cross_tool/lib/gcc/arm-none-linux-gnueabi/4.3.4/../../../../arm-none-linux-gnueabi/bin/ld: /opt/crosstool/build-gold/work/obj.glibc/elf/librtld.os: in function _dl_start_final:rtld.c(.text+0x4f8): error: undefined reference to '_begin'
collect2: ld returned 1 exit status

[-- Attachment #3: binutils-gold-make-ld-script-cmd-line.txt --]
[-- Type: text/plain, Size: 364 bytes --]

arm-none-linux-gnueabi-gcc   -nostdlib -nostartfiles -shared 	\
		  -Wl,-z,combreloc -Wl,-z,relro -Wl,--hash-style=both -Wl,-z,defs -Wl,--verbose 2>&1 |	\
		  LC_ALL=C \
		  sed -e '/^=========/,/^=========/!d;/^=========/d'	\
		      -e 's/\. = .* + SIZEOF_HEADERS;/& _begin = . - SIZEOF_HEADERS;/' \
		  > /opt/crosstool/build-gold/work/obj.glibc/elf/ld.so.lds


[-- Attachment #4: ld.so.lds-needed --]
[-- Type: text/x-csrc, Size: 7337 bytes --]

/* Script for --shared -z combreloc: shared library, combine & sort relocs */
OUTPUT_FORMAT("elf32-littlearm", "elf32-bigarm",
	      "elf32-littlearm")
OUTPUT_ARCH(arm)
ENTRY(_start)
SEARCH_DIR("=/usr/local/lib"); SEARCH_DIR("=/lib"); SEARCH_DIR("=/usr/lib");
SECTIONS
{
  /* Read-only sections, merged into text segment: */
  . = SEGMENT_START("text-segment", 0) + SIZEOF_HEADERS; _begin = . - SIZEOF_HEADERS;
  .note.gnu.build-id : { *(.note.gnu.build-id) }
  .hash           : { *(.hash) }
  .gnu.hash       : { *(.gnu.hash) }
  .dynsym         : { *(.dynsym) }
  .dynstr         : { *(.dynstr) }
  .gnu.version    : { *(.gnu.version) }
  .gnu.version_d  : { *(.gnu.version_d) }
  .gnu.version_r  : { *(.gnu.version_r) }
  .rel.dyn        :
    {
      *(.rel.init)
      *(.rel.text .rel.text.* .rel.gnu.linkonce.t.*)
      *(.rel.fini)
      *(.rel.rodata .rel.rodata.* .rel.gnu.linkonce.r.*)
      *(.rel.data.rel.ro* .rel.gnu.linkonce.d.rel.ro.*)
      *(.rel.data .rel.data.* .rel.gnu.linkonce.d.*)
      *(.rel.tdata .rel.tdata.* .rel.gnu.linkonce.td.*)
      *(.rel.tbss .rel.tbss.* .rel.gnu.linkonce.tb.*)
      *(.rel.ctors)
      *(.rel.dtors)
      *(.rel.got)
      *(.rel.bss .rel.bss.* .rel.gnu.linkonce.b.*)
    }
  .rel.ifunc.dyn        :
    {
      *(.rel.ifunc.*)
    }
  .rela.dyn       :
    {
      *(.rela.init)
      *(.rela.text .rela.text.* .rela.gnu.linkonce.t.*)
      *(.rela.fini)
      *(.rela.rodata .rela.rodata.* .rela.gnu.linkonce.r.*)
      *(.rela.data .rela.data.* .rela.gnu.linkonce.d.*)
      *(.rela.tdata .rela.tdata.* .rela.gnu.linkonce.td.*)
      *(.rela.tbss .rela.tbss.* .rela.gnu.linkonce.tb.*)
      *(.rela.ctors)
      *(.rela.dtors)
      *(.rela.got)
      *(.rela.bss .rela.bss.* .rela.gnu.linkonce.b.*)
    }
  .rela.ifunc.dyn       :
    {
      *(.rela.ifunc.*)
    }
  .rel.plt        : { *(.rel.plt) }
  .rela.plt       : { *(.rela.plt) }
  .init           :
  {
    KEEP (*(.init))
  } =0
  .plt            : { *(.plt) }
  .text           :
  {
    *(.text .stub .text.* .gnu.linkonce.t.*)
    /* .gnu.warning sections are handled specially by elf32.em.  */
    *(.gnu.warning)
    *(.glue_7t) *(.glue_7) *(.vfp11_veneer) *(.v4_bx)
  } =0
  .fini           :
  {
    KEEP (*(.fini))
  } =0
  PROVIDE (__etext = .);
  PROVIDE (_etext = .);
  PROVIDE (etext = .);
  .rodata         : { *(.rodata .rodata.* .gnu.linkonce.r.*) }
  .rodata1        : { *(.rodata1) }
  .ARM.extab   : { *(.ARM.extab* .gnu.linkonce.armextab.*) }
   __exidx_start = .;
  .ARM.exidx   : { *(.ARM.exidx* .gnu.linkonce.armexidx.*) }
   __exidx_end = .;
  .eh_frame_hdr : { *(.eh_frame_hdr) }
  .eh_frame       : ONLY_IF_RO { KEEP (*(.eh_frame)) }
  .gcc_except_table   : ONLY_IF_RO { *(.gcc_except_table .gcc_except_table.*) }
  /* Adjust the address for the data segment.  We want to adjust up to
     the same address within the page on the next page up.  */
  . = ALIGN (CONSTANT (MAXPAGESIZE)) - ((CONSTANT (MAXPAGESIZE) - .) & (CONSTANT (MAXPAGESIZE) - 1)); . = DATA_SEGMENT_ALIGN (CONSTANT (MAXPAGESIZE), CONSTANT (COMMONPAGESIZE));
  /* Exception handling  */
  .eh_frame       : ONLY_IF_RW { KEEP (*(.eh_frame)) }
  .gcc_except_table   : ONLY_IF_RW { *(.gcc_except_table .gcc_except_table.*) }
  /* Thread Local Storage sections  */
  .tdata	  : { *(.tdata .tdata.* .gnu.linkonce.td.*) }
  .tbss		  : { *(.tbss .tbss.* .gnu.linkonce.tb.*) *(.tcommon) }
  .preinit_array     :
  {
    KEEP (*(.preinit_array))
  }
  .init_array     :
  {
     KEEP (*(SORT(.init_array.*)))
     KEEP (*(.init_array))
  }
  .fini_array     :
  {
    KEEP (*(.fini_array))
    KEEP (*(SORT(.fini_array.*)))
  }
  .ctors          :
  {
    /* gcc uses crtbegin.o to find the start of
       the constructors, so we make sure it is
       first.  Because this is a wildcard, it
       doesn't matter if the user does not
       actually link against crtbegin.o; the
       linker won't look for a file to match a
       wildcard.  The wildcard also means that it
       doesn't matter which directory crtbegin.o
       is in.  */
    KEEP (*crtbegin.o(.ctors))
    KEEP (*crtbegin?.o(.ctors))
    /* We don't want to include the .ctor section from
       the crtend.o file until after the sorted ctors.
       The .ctor section from the crtend file contains the
       end of ctors marker and it must be last */
    KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o ) .ctors))
    KEEP (*(SORT(.ctors.*)))
    KEEP (*(.ctors))
  }
  .dtors          :
  {
    KEEP (*crtbegin.o(.dtors))
    KEEP (*crtbegin?.o(.dtors))
    KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o ) .dtors))
    KEEP (*(SORT(.dtors.*)))
    KEEP (*(.dtors))
  }
  .jcr            : { KEEP (*(.jcr)) }
  .data.rel.ro : { *(.data.rel.ro.local* .gnu.linkonce.d.rel.ro.local.*) *(.data.rel.ro* .gnu.linkonce.d.rel.ro.*) }
  .dynamic        : { *(.dynamic) }
  . = DATA_SEGMENT_RELRO_END (0, .);
  .got            : { *(.got.plt) *(.got) }
  .data           :
  {
    __data_start = . ;
    *(.data .data.* .gnu.linkonce.d.*)
    SORT(CONSTRUCTORS)
  }
  .data1          : { *(.data1) }
  _edata = .; PROVIDE (edata = .);
  __bss_start = .;
  __bss_start__ = .;
  .bss            :
  {
   *(.dynbss)
   *(.bss .bss.* .gnu.linkonce.b.*)
   *(COMMON)
   /* Align here to ensure that the .bss section occupies space up to
      _end.  Align after .bss to ensure correct alignment even if the
      .bss section disappears because there are no input sections.
      FIXME: Why do we need it? When there is no .bss section, we don't
      pad the .data section.  */
   . = ALIGN(. != 0 ? 32 / 8 : 1);
  }
  _bss_end__ = . ; __bss_end__ = . ;
  . = ALIGN(32 / 8);
  . = ALIGN(32 / 8);
  __end__ = . ;
  _end = .; PROVIDE (end = .);
  . = DATA_SEGMENT_END (.);
  /* Stabs debugging sections.  */
  .stab          0 : { *(.stab) }
  .stabstr       0 : { *(.stabstr) }
  .stab.excl     0 : { *(.stab.excl) }
  .stab.exclstr  0 : { *(.stab.exclstr) }
  .stab.index    0 : { *(.stab.index) }
  .stab.indexstr 0 : { *(.stab.indexstr) }
  .comment       0 : { *(.comment) }
  /* DWARF debug sections.
     Symbols in the DWARF debugging sections are relative to the beginning
     of the section so we begin them at 0.  */
  /* DWARF 1 */
  .debug          0 : { *(.debug) }
  .line           0 : { *(.line) }
  /* GNU DWARF 1 extensions */
  .debug_srcinfo  0 : { *(.debug_srcinfo) }
  .debug_sfnames  0 : { *(.debug_sfnames) }
  /* DWARF 1.1 and DWARF 2 */
  .debug_aranges  0 : { *(.debug_aranges) }
  .debug_pubnames 0 : { *(.debug_pubnames) }
  /* DWARF 2 */
  .debug_info     0 : { *(.debug_info .gnu.linkonce.wi.*) }
  .debug_abbrev   0 : { *(.debug_abbrev) }
  .debug_line     0 : { *(.debug_line) }
  .debug_frame    0 : { *(.debug_frame) }
  .debug_str      0 : { *(.debug_str) }
  .debug_loc      0 : { *(.debug_loc) }
  .debug_macinfo  0 : { *(.debug_macinfo) }
  /* SGI/MIPS DWARF 2 extensions */
  .debug_weaknames 0 : { *(.debug_weaknames) }
  .debug_funcnames 0 : { *(.debug_funcnames) }
  .debug_typenames 0 : { *(.debug_typenames) }
  .debug_varnames  0 : { *(.debug_varnames) }
  /* DWARF 3 */
  .debug_pubtypes 0 : { *(.debug_pubtypes) }
  .debug_ranges   0 : { *(.debug_ranges) }
  .gnu.attributes 0 : { KEEP (*(.gnu.attributes)) }
  .note.gnu.arm.ident 0 : { KEEP (*(.note.gnu.arm.ident)) }
  /DISCARD/ : { *(.note.GNU-stack) *(.gnu_debuglink) }
}



^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2010-02-11  3:00 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-02-10 23:06 [GOLD][PATCH] predefined segment symbol _begin Viktor Kutuzov
2010-02-11  0:11 ` Ian Lance Taylor
2010-02-11  0:41   ` Viktor Kutuzov
2010-02-11  1:16     ` Ian Lance Taylor
2010-02-11  3:00       ` Viktor Kutuzov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).