[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Cross compile



<10007180619.AA00274@lachesis.sm.sony.co.jp>の記事において
shin@sm.sony.co.jpさんは書きました。

> > >pkgsrcのcross compilerを使って作成された.soは動作しないという問題が既に
> > >発覚しています(dynamic linkされた実行ファイルが必ずcoreを吐く)。この問題
> > >のために、20000620-1.5のsnapshotは使えません。

> 問題の原因は、pkgsrcのcross linkerがNetBSDで追加されたオプション 
> '-nostdlib'を知らないために、それを'-n'であると解釈する部分にあるようで
> す。'-n'はNMAGICのファイルを出力するオプションなので、アライメントやアド
> レスが変になります。

いまさらですが、 ld に -nostdlib のオプションが足されたときの
変更を cvs diff で引っ張ってきて現状の cross/binutils 用の
patch にしてみました。

添付の patch を pkgsrc/cross/binutils/patches/patch-am として
置いてみてうまくいくか試して頂けないでしょうか?
一応 ld が -nostdlib つきで作成されるのは確認しましたが、
cross で userland を作る環境を作っていないもので……
---
Izumi Tsutsui
tsutsui@ceres.dti.ne.jp

Index: ld/ld.h
===================================================================
RCS file: /cvs/cvsroot/gnusrc/gnu/dist/ld/ld.h,v
retrieving revision 1.1.1.2
retrieving revision 1.2
diff -u -r1.1.1.2 -r1.2
--- ld.h	1999/02/02 19:53:45	1.1.1.2
+++ ld.h	1999/02/05 19:48:07	1.2
@@ -117,6 +117,9 @@
   /* If true, doing a dynamic link.  */
   boolean dynamic_link;
 
+  /* If true, do not use SEARCH_DIR directives from the linker script.  */
+  boolean no_std_path;
+
   /* If true, build constructors.  */
   boolean build_constructors;
 
Index: ld/ldgram.y
===================================================================
RCS file: /cvs/cvsroot/gnusrc/gnu/dist/ld/ldgram.y,v
retrieving revision 1.1.1.2
retrieving revision 1.2
diff -u -r1.1.1.2 -r1.2
--- ldgram.y	1999/02/02 19:53:47	1.1.1.2
+++ ldgram.y	1999/02/05 19:48:07	1.2
@@ -295,7 +295,7 @@
 	|	TARGET_K '(' NAME ')'
 		{ lang_add_target($3); }
 	|	SEARCH_DIR '(' filename ')'
-		{ ldfile_add_library_path ($3, false); }
+		{ if (!config.no_std_path) ldfile_add_library_path ($3, false); }
 	|	OUTPUT '(' filename ')'
 		{ lang_add_output($3, 1); }
         |	OUTPUT_FORMAT '(' NAME ')'
Index: ld/ldmain.c
===================================================================
RCS file: /cvs/cvsroot/gnusrc/gnu/dist/ld/ldmain.c,v
retrieving revision 1.1.1.3
retrieving revision 1.2
diff -u -r1.1.1.3 -r1.2
--- ldmain.c	1999/02/02 19:53:48	1.1.1.3
+++ ldmain.c	1999/02/05 19:48:08	1.2
@@ -188,6 +188,7 @@
   whole_archive = false;
   config.build_constructors = true;
   config.dynamic_link = false;
+  config.no_std_path = (getenv("LD_NOSTD_PATH") ? true : false);
   command_line.force_common_definition = false;
   command_line.interpreter = NULL;
   command_line.rpath = NULL;
Index: ld/lexsup.c
===================================================================
RCS file: /cvs/cvsroot/gnusrc/gnu/dist/ld/lexsup.c,v
retrieving revision 1.1.1.2
retrieving revision 1.3
diff -u -r1.1.1.2 -r1.3
--- lexsup.c	1999/02/02 19:53:48	1.1.1.2
+++ lexsup.c	1999/02/05 19:48:08	1.3
@@ -111,6 +111,7 @@
 #define OPTION_WHOLE_ARCHIVE		(OPTION_SPLIT_BY_FILE + 1)
 #define OPTION_WRAP			(OPTION_WHOLE_ARCHIVE + 1)
 #define OPTION_FORCE_EXE_SUFFIX		(OPTION_WRAP + 1)
+#define OPTION_NO_STD_PATH		(OPTION_FORCE_EXE_SUFFIX + 16)
 
 /* The long options.  This structure is used for both the option
    parsing and the help text.  */
@@ -266,6 +267,8 @@
       '\0', NULL, "Create an output file even if errors occur", TWO_DASHES },
   { {"noinhibit_exec", no_argument, NULL, OPTION_NOINHIBIT_EXEC},
       '\0', NULL, NULL, NO_HELP },
+  { {"nostdlib", no_argument, NULL, OPTION_NO_STD_PATH}, /* NetBSD.  */
+      '\0', NULL, "Do not use default library search path", ONE_DASH },
   { {"oformat", required_argument, NULL, OPTION_OFORMAT},
       '\0', "TARGET", "Specify target of output file", TWO_DASHES },
   { {"qmagic", no_argument, NULL, OPTION_IGNORE},
@@ -283,7 +286,7 @@
       '\0', "PATH", "Set link time shared library search path", ONE_DASH },
   { {"shared", no_argument, NULL, OPTION_SHARED},
       '\0', NULL, "Create a shared library", ONE_DASH },
-  { {"Bshareable", no_argument, NULL, OPTION_SHARED }, /* FreeBSD.  */
+  { {"Bshareable", no_argument, NULL, OPTION_SHARED }, /* FreeBSD, NetBSD.  */
       '\0', NULL, NULL, ONE_DASH },
   { {"sort-common", no_argument, NULL, OPTION_SORT_COMMON},
       '\0', NULL, "Sort common symbols by size", TWO_DASHES },
@@ -327,6 +330,8 @@
       TWO_DASHES },
   { {"whole-archive", no_argument, NULL, OPTION_WHOLE_ARCHIVE},
       '\0', NULL, "Include all objects from following archives", TWO_DASHES },
+  { {"Bforcearchive", no_argument, NULL, OPTION_WHOLE_ARCHIVE }, /* NetBSD.  */
+      '\0', NULL, NULL, ONE_DASH },
   { {"wrap", required_argument, NULL, OPTION_WRAP},
       '\0', "SYMBOL", "Use wrapper functions for SYMBOL", TWO_DASHES }
 };
@@ -580,6 +585,9 @@
 	  break;
 	case OPTION_NO_KEEP_MEMORY:
 	  link_info.keep_memory = false;
+	  break;
+	case OPTION_NO_STD_PATH:
+	  config.no_std_path = true;
 	  break;
 	case OPTION_NO_WARN_MISMATCH:
 	  command_line.warn_mismatch = false;