This is the mail archive of the cygwin mailing list for the Cygwin 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: undefined reference to `___real__Znwj'


jojelino wrote:

>> make -j 10 because of speed gain.
> and it complains.. which i reported it.
> so i got
>> cd i686-pc-cygwin/winsup
> and >make  again.
> and it complains when it comes to cygserver.exe
> 
> this could be answer for your question?????

  I was just curious how you got as far as building cygserver.exe without
running into earlier problems compiling the cygwin1.dll; it doesn't build
using 4.5.0 without a lot of patching.

  Anyway, thanks for the bug report; you reminded me that I stumbled across
this bug earlier in the summer but put it to one side because 4.5.0 was still
a long way from release.  Time to fix it, particularly now that the libstdc++
changes have gone in.

  The problem is a bug in the linker, so you'll need to check out binutils
from sourceware.org cvs and apply the attached
weaksyms-vs-undefs-order-of-ref-fix-take-2.diff patch.  You'll also need the
other attached patch for the winsup/cygwin repository before it will all
compile correctly with 4.5.0; there are a number of aliasing problems to which
4.5.0 is more sensitive than earlier GCCs.

  (I'll be feeding these patches back upstream in due course, once I've given
them all some further testing, but they build an apparently fully working
4.5.0-compiled cygwin1.dll so far, anyway.)

    cheers,
      DaveK
Index: bfd/cofflink.c
===================================================================
RCS file: /cvs/src/src/bfd/cofflink.c,v
retrieving revision 1.73
diff -p -u -r1.73 cofflink.c
--- bfd/cofflink.c	10 Oct 2009 04:58:48 -0000	1.73
+++ bfd/cofflink.c	18 Dec 2009 18:09:03 -0000
@@ -466,6 +466,30 @@ coff_link_add_symbols (bfd *abfd,
 		goto error_return;
 	    }
 
+	  if (obj_pe (abfd) && (flags & BSF_WEAK) != 0 && addit && sym_hash 
+		&& (*sym_hash)->root.type == bfd_link_hash_undefined)
+	    {
+	      /* If we try to add a PE weak external after having already
+	         seen an undefined reference to it in an earlier object,
+		 _bfd_generic_link_add_one_symbol will return the hash
+		 entry for the original symbol, and we'll lose track of
+		 the actual weak external definition and its associated
+		 auxiliary symbol containing the default value, leading
+		 to an undefined reference error at the end of linking.
+		 So here, if we are adding a weak external, and the sym_hash
+		 returned an existing undefined hash entry, we update the
+		 returned entry with the details of the new symbol.  */
+	      if ((*sym_hash)->symbol_class != C_NT_WEAK)
+		{
+		  (*sym_hash)->symbol_class = C_NT_WEAK;
+		  (*sym_hash)->root.type = bfd_link_hash_undefweak;
+		  (*sym_hash)->root.u.undef.abfd = abfd;
+		  (*sym_hash)->root.u.undef.weak = abfd;
+		  /* Now fix the undefs chain.  */
+		  bfd_link_repair_undef_list (info->hash);
+		}
+	    }
+
 	  if (obj_pe (abfd) && (flags & BSF_SECTION_SYM) != 0)
 	    (*sym_hash)->coff_link_hash_flags |=
 	      COFF_LINK_HASH_PE_SECTION_SYMBOL;
? newlib/libc/libc.info
? newlib/libm/libm.info
? winsup/cygwin/gendef.unwind
Index: winsup/cygwin/fhandler.h
===================================================================
RCS file: /cvs/src/src/winsup/cygwin/fhandler.h,v
retrieving revision 1.385
diff -p -u -r1.385 fhandler.h
--- winsup/cygwin/fhandler.h	16 Dec 2009 14:56:10 -0000	1.385
+++ winsup/cygwin/fhandler.h	18 Dec 2009 13:41:23 -0000
@@ -291,6 +291,18 @@ class fhandler_base
 			      DWORD nNumberOfLinks,
 			      DWORD dwFileAttributes)
     __attribute__ ((regparm (3)));
+  int __stdcall fstat_helper (struct __stat64 *buf,
+			      LARGE_INTEGER ftChangeTime,
+			      LARGE_INTEGER ftLastAccessTime,
+			      LARGE_INTEGER ftLastWriteTime,
+			      LARGE_INTEGER ftCreationTime,
+			      DWORD dwVolumeSerialNumber,
+			      ULONGLONG nFileSize,
+			      LONGLONG nAllocSize,
+			      ULONGLONG nFileIndex,
+			      DWORD nNumberOfLinks,
+			      DWORD dwFileAttributes)
+    __attribute__ ((regparm (3)));
   int __stdcall fstat_by_nfs_ea (struct __stat64 *buf) __attribute__ ((regparm (2)));
   int __stdcall fstat_by_handle (struct __stat64 *buf) __attribute__ ((regparm (2)));
   int __stdcall fstat_by_name (struct __stat64 *buf) __attribute__ ((regparm (2)));
Index: winsup/cygwin/fhandler_disk_file.cc
===================================================================
RCS file: /cvs/src/src/winsup/cygwin/fhandler_disk_file.cc,v
retrieving revision 1.318
diff -p -u -r1.318 fhandler_disk_file.cc
--- winsup/cygwin/fhandler_disk_file.cc	27 Nov 2009 14:27:22 -0000	1.318
+++ winsup/cygwin/fhandler_disk_file.cc	18 Dec 2009 13:41:23 -0000
@@ -373,11 +373,11 @@ fhandler_base::fstat_by_handle (struct _
   pc.file_attributes (fbi.FileAttributes);
   return fstat_helper (buf,
 		   fbi.ChangeTime.QuadPart
-		   ? *(FILETIME *) (void *) &fbi.ChangeTime
-		   : *(FILETIME *) (void *) &fbi.LastWriteTime,
-		   *(FILETIME *) (void *) &fbi.LastAccessTime,
-		   *(FILETIME *) (void *) &fbi.LastWriteTime,
-		   *(FILETIME *) (void *) &fbi.CreationTime,
+		   ? fbi.ChangeTime
+		   : fbi.LastWriteTime,
+		   fbi.LastAccessTime,
+		   fbi.LastWriteTime,
+		   fbi.CreationTime,
 		   get_dev (),
 		   fsi.EndOfFile.QuadPart,
 		   fsi.AllocationSize.QuadPart,
@@ -441,11 +441,11 @@ fhandler_base::fstat_by_name (struct __s
   pc.file_attributes (fdi_buf.fdi.FileAttributes);
   return fstat_helper (buf,
 		       fdi_buf.fdi.ChangeTime.QuadPart ?
-		       *(FILETIME *) (void *) &fdi_buf.fdi.ChangeTime :
-		       *(FILETIME *) (void *) &fdi_buf.fdi.LastWriteTime,
-		       *(FILETIME *) (void *) &fdi_buf.fdi.LastAccessTime,
-		       *(FILETIME *) (void *) &fdi_buf.fdi.LastWriteTime,
-		       *(FILETIME *) (void *) &fdi_buf.fdi.CreationTime,
+		       fdi_buf.fdi.ChangeTime :
+		       fdi_buf.fdi.LastWriteTime,
+		       fdi_buf.fdi.LastAccessTime,
+		       fdi_buf.fdi.LastWriteTime,
+		       fdi_buf.fdi.CreationTime,
 		       pc.fs_serial_number (),
 		       fdi_buf.fdi.EndOfFile.QuadPart,
 		       fdi_buf.fdi.AllocationSize.QuadPart,
@@ -458,10 +458,10 @@ too_bad:
   /* Arbitrary value: 2006-12-01 */
   RtlSecondsSince1970ToTime (1164931200L, &ft);
   return fstat_helper (buf,
-		       *(FILETIME *) (void *) &ft,
-		       *(FILETIME *) (void *) &ft,
-		       *(FILETIME *) (void *) &ft,
-		       *(FILETIME *) (void *) &ft,
+		       ft,
+		       ft,
+		       ft,
+		       ft,
 		       0,
 		       0ULL,
 		       -1LL,
@@ -692,6 +692,28 @@ fhandler_base::fstat_helper (struct __st
 }
 
 int __stdcall
+fhandler_base::fstat_helper (struct __stat64 *buf,
+			     LARGE_INTEGER ftChangeTime,
+			     LARGE_INTEGER ftLastAccessTime,
+			     LARGE_INTEGER ftLastWriteTime,
+			     LARGE_INTEGER ftCreationTime,
+			     DWORD dwVolumeSerialNumber,
+			     ULONGLONG nFileSize,
+			     LONGLONG nAllocSize,
+			     ULONGLONG nFileIndex,
+			     DWORD nNumberOfLinks,
+			     DWORD dwFileAttributes)
+{
+  return fstat_helper (buf,
+	((FILETIME) {ftChangeTime.u.LowPart, ftChangeTime.u.HighPart}),
+	((FILETIME) {ftLastAccessTime.u.LowPart, ftLastAccessTime.u.HighPart}),
+	((FILETIME) {ftLastWriteTime.u.LowPart, ftLastWriteTime.u.HighPart}),
+	((FILETIME) {ftCreationTime.u.LowPart, ftCreationTime.u.HighPart}),
+	dwVolumeSerialNumber, nFileSize, nAllocSize,
+	nFileIndex, nNumberOfLinks, dwFileAttributes);
+}
+
+int __stdcall
 fhandler_disk_file::fstat (struct __stat64 *buf)
 {
   return fstat_fs (buf);
Index: winsup/cygwin/fhandler_floppy.cc
===================================================================
RCS file: /cvs/src/src/winsup/cygwin/fhandler_floppy.cc,v
retrieving revision 1.55
diff -p -u -r1.55 fhandler_floppy.cc
--- winsup/cygwin/fhandler_floppy.cc	24 Jul 2009 20:54:33 -0000	1.55
+++ winsup/cygwin/fhandler_floppy.cc	18 Dec 2009 13:41:23 -0000
@@ -56,7 +56,8 @@ fhandler_dev_floppy::get_drive_info (str
 	__seterrno ();
       else
 	{
-	  di = &((DISK_GEOMETRY_EX *) dbuf)->Geometry;
+	  DISK_GEOMETRY_EX *dgx = (DISK_GEOMETRY_EX *) dbuf;
+	  di = &dgx->Geometry;
 	  if (!DeviceIoControl (get_handle (),
 				IOCTL_DISK_GET_PARTITION_INFO_EX, NULL, 0,
 				pbuf, 256, &bytes_read, NULL))
Index: winsup/cygwin/fhandler_proc.cc
===================================================================
RCS file: /cvs/src/src/winsup/cygwin/fhandler_proc.cc,v
retrieving revision 1.87
diff -p -u -r1.87 fhandler_proc.cc
--- winsup/cygwin/fhandler_proc.cc	9 Jun 2009 09:45:29 -0000	1.87
+++ winsup/cygwin/fhandler_proc.cc	18 Dec 2009 13:41:23 -0000
@@ -637,7 +637,9 @@ format_proc_cpuinfo (void *, char *&dest
 	  read_value ("Identifier", REG_SZ);
 	  bufptr += __small_sprintf (bufptr, "identifier      : %s\n", szBuffer);
 	  read_value ("~Mhz", REG_DWORD);
-	  bufptr += __small_sprintf (bufptr, "cpu MHz         : %u\n", *(DWORD *) szBuffer);
+	  union { char szbuff[sizeof (DWORD)]; DWORD dw; } u;
+	  memcpy (u.szbuff, szBuffer, sizeof (DWORD));
+	  bufptr += __small_sprintf (bufptr, "cpu MHz         : %u\n", u.dw);
 
 	  print ("flags           :");
 	  if (IsProcessorFeaturePresent (PF_3DNOW_INSTRUCTIONS_AVAILABLE))
@@ -675,7 +677,9 @@ format_proc_cpuinfo (void *, char *&dest
 	  bufptr += __small_sprintf (bufptr, "vendor_id\t: %s\n",
 				     (char *)vendor_id);
 	  read_value ("~Mhz", REG_DWORD);
-	  unsigned cpu_mhz = *(DWORD *)szBuffer;
+	  union { char szbuff[sizeof (DWORD)]; DWORD dw; } u;
+	  memcpy (u.szbuff, szBuffer, sizeof (DWORD));
+	  unsigned cpu_mhz = u.dw;
 	  if (maxf >= 1)
 	    {
 	      unsigned features2, features1, extra_info, cpuid_sig;
Index: winsup/cygwin/fhandler_tty.cc
===================================================================
RCS file: /cvs/src/src/winsup/cygwin/fhandler_tty.cc,v
retrieving revision 1.190
diff -p -u -r1.190 fhandler_tty.cc
--- winsup/cygwin/fhandler_tty.cc	24 Jul 2009 20:54:33 -0000	1.190
+++ winsup/cygwin/fhandler_tty.cc	18 Dec 2009 13:41:24 -0000
@@ -225,6 +225,7 @@ process_input (void *)
 	  == line_edit_signalled)
 	tty_master->console->eat_readahead (-1);
     }
+  return 0;
 }
 
 bool
@@ -438,6 +439,7 @@ process_ioctl (void *)
 				  : (void *) &ttyp->arg);
       SetEvent (tty_master->ioctl_done_event);
     }
+  return 0;
 }
 
 /**********************************************************************/
Index: winsup/cygwin/hookapi.cc
===================================================================
RCS file: /cvs/src/src/winsup/cygwin/hookapi.cc,v
retrieving revision 1.19
diff -p -u -r1.19 hookapi.cc
--- winsup/cygwin/hookapi.cc	11 Sep 2008 04:34:23 -0000	1.19
+++ winsup/cygwin/hookapi.cc	18 Dec 2009 13:41:24 -0000
@@ -252,7 +252,7 @@ hook_or_detect_cygwin (const char *name,
   fh.origfn = NULL;
   fh.hookfn = fn;
   char *buf = (char *) alloca (strlen (name) + sizeof ("_64"));
-  int i;
+  int i = -1;
   // Iterate through each import descriptor, and redirect if appropriate
   for (PIMAGE_IMPORT_DESCRIPTOR pd = pdfirst; pd->FirstThunk; pd++)
     {
cvs diff: winsup/cygwin/how-crt-and-initfini.txt is a new entry, no comparison available
cvs diff: winsup/cygwin/how-cxx-abi.txt is a new entry, no comparison available
Index: winsup/cygwin/passwd.cc
===================================================================
RCS file: /cvs/src/src/winsup/cygwin/passwd.cc,v
retrieving revision 1.84
diff -p -u -r1.84 passwd.cc
--- winsup/cygwin/passwd.cc	26 Jan 2009 13:20:46 -0000	1.84
+++ winsup/cygwin/passwd.cc	18 Dec 2009 13:41:24 -0000
@@ -98,11 +98,14 @@ internal_getpwsid (cygpsid &sid)
     {
       endptr = strchr (sid_string + 2, 0) - 1;
       for (int i = 0; i < pr.curr_lines; i++)
-	if ((pw = passwd_buf + i)->pw_dir > pw->pw_gecos + 8)
-	  for (ptr1 = endptr, ptr2 = pw->pw_dir - 2;
-	       *ptr1 == *ptr2; ptr2--)
+	{
+	  pw = passwd_buf + i;
+	  if (pw->pw_dir > pw->pw_gecos + 8)
+	    for (ptr1 = endptr, ptr2 = pw->pw_dir - 2;
+	      *ptr1 == *ptr2; ptr2--)
 	    if (!*--ptr1)
 	      return pw;
+	}
     }
   return NULL;
 }
Index: winsup/cygwin/syscalls.cc
===================================================================
RCS file: /cvs/src/src/winsup/cygwin/syscalls.cc,v
retrieving revision 1.548
diff -p -u -r1.548 syscalls.cc
--- winsup/cygwin/syscalls.cc	17 Dec 2009 18:33:05 -0000	1.548
+++ winsup/cygwin/syscalls.cc	18 Dec 2009 13:41:24 -0000
@@ -3641,8 +3641,12 @@ long gethostid (void)
     status = UuidCreate (&Uuid);
   if (status == RPC_S_OK)
     {
-      data[4] = *(unsigned *)&Uuid.Data4[2];
-      data[5] = *(unsigned short *)&Uuid.Data4[6];
+      unsigned d4;
+      unsigned short d5;
+      memcpy (&d4, &Uuid.Data4[2], sizeof (unsigned));
+      memcpy (&d5, &Uuid.Data4[6], sizeof (unsigned short));
+      data[4] = d4;
+      data[5] = d5;
       // Unfortunately Windows will sometimes pick a virtual Ethernet card
       // e.g. VMWare Virtual Ethernet Adaptor
       debug_printf ("MAC address of first Ethernet card: %02x:%02x:%02x:%02x:%02x:%02x",
Index: winsup/cygwin/include/cygwin/in6.h
===================================================================
RCS file: /cvs/src/src/winsup/cygwin/include/cygwin/in6.h,v
retrieving revision 1.6
diff -p -u -r1.6 in6.h
--- winsup/cygwin/include/cygwin/in6.h	18 Jan 2007 10:25:40 -0000	1.6
+++ winsup/cygwin/include/cygwin/in6.h	18 Dec 2009 13:41:24 -0000
@@ -16,10 +16,7 @@ details. */
 #define INET6_ADDRSTRLEN 46
 
 #define IN6_ARE_ADDR_EQUAL(a, b) \
-	(((const uint32_t *)(a))[0] == ((const uint32_t *)(b))[0] \
-	 && ((const uint32_t *)(a))[1] == ((const uint32_t *)(b))[1] \
-	 && ((const uint32_t *)(a))[2] == ((const uint32_t *)(b))[2] \
-	 && ((const uint32_t *)(a))[3] == ((const uint32_t *)(b))[3])
+	(!memcmp ((a), (b), 4 * sizeof (uint32_t)))
 
 #define IN6_IS_ADDR_UNSPECIFIED(addr) \
 	(((const uint32_t *)(addr))[0] == 0 \

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

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