public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* set sysroot command on AIX has no effect.
@ 2016-09-13  9:05 Sangamesh Mallayya
  2016-09-29 15:33 ` Ulrich Weigand
  0 siblings, 1 reply; 16+ messages in thread
From: Sangamesh Mallayya @ 2016-09-13  9:05 UTC (permalink / raw)
  To: gdb-patches

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

set sysroot command on AIX has no effect if a program depends on shared 
library archives (.a).

This is the original behaviour if we use "set sysroot" command.

(gdb) set sysroot /tmp
warning: while parsing aix library list: no element found
(gdb) file /home/sysroot/testApp
Reading symbols from /home/sysroot/testApp...done.
(gdb) core-file /home/sysroot/core
warning: core file may not match specified executable file.
warning: Unexpected size of section `.reg' in core file.
warning: Could not open `/home/sysroot/libTest.a' as an executable file: A 
file or directory in the path name does not exist.
warning: Could not load shared library symbols for 
/home/sysroot/libTest.a(func.o).
Do you need "set solib-search-path" or "set sysroot"?
Program terminated with signal SIGABRT, Aborted.
warning: Unexpected size of section `.reg' in core file.
#0  0xd013a820 in raise () from /usr/lib/libc.a(shr.o)
(gdb) info sharedlibrary 
From        To          Syms Read   Shared Object Library
0xd04da240  0xd04daa3e  Yes (*)     /usr/lib/libcrypt.a(shr.o)
                                        No /home/sysroot/libTest.a(func.o)
0xd010c880  0xd049b13d  Yes (*)     /usr/lib/libc.a(shr.o)
(*): Shared library is missing debugging information.
(gdb) bt
#0  0xd013a820 in raise () from /usr/lib/libc.a(shr.o)
#1  0xd01b3088 in abort () from /usr/lib/libc.a(shr.o)
#2  0xd2fd82a4 in ?? ()
#3  0x100003a4 in main () at main.c:8
(gdb) 
 

After applying the attached patch.
Patch doesn't cause any change in original behaviour while handling shared 
library with .so names.

".a" name archives case.

(gdb) set sysroot /tmp 
warning: while parsing aix library list: no element found
(gdb) file /home/sysroot/testApp 
Reading symbols from /home/sysroot/testApp...done.
(gdb) core-file /home/sysroot/core
warning: core file may not match specified executable file.
warning: Unexpected size of section `.reg' in core file.
Program terminated with signal SIGABRT, Aborted.
warning: Unexpected size of section `.reg' in core file.
#0  0xd013a820 in raise () from /tmp/usr/lib/libc.a(shr.o)
(gdb) inf sharedlibrary 
From             To                   Syms Read   Shared Object Library
0xd04da240  0xd04daa3e  Yes    (*)       /tmp/usr/lib/libcrypt.a(shr.o)
0xd2fd6250   0xd2fd64aa   Yes /tmp/home/sysroot/libTest.a(func.o)
0xd010c880  0xd049b13d  Yes    (*)       /tmp/usr/lib/libc.a(shr.o)
(*): Shared library is missing debugging information.
(gdb) bt
#0  0xd013a820 in raise () from /tmp/usr/lib/libc.a(shr.o)
#1  0xd01b3088 in abort () from /tmp/usr/lib/libc.a(shr.o)
#2  0xd2fd6364 in func () from /tmp/home/sysroot/libTest.a(func.o)
#3  0x100003a4 in main () at main.c:8
(gdb) 


.a & .so library names

(gdb) set sysroot /tmp
warning: while parsing aix library list: no element found
(gdb) file /home/sysroot/testApp 
Reading symbols from /home/sysroot/testApp...done.
(gdb) core-file /home/sysroot/core
warning: core file may not match specified executable file.
warning: Unexpected size of section `.reg' in core file.
Program terminated with signal SIGABRT, Aborted.
warning: Unexpected size of section `.reg' in core file.
#0  0xd013a820 in raise () from /tmp/usr/lib/libc.a(shr.o)
(gdb) info sharedlibrary 
From             To                   Syms Read   Shared Object Library
0xd04da240  0xd04daa3e  Yes    (*)        /tmp/usr/lib/libcrypt.a(shr.o)
0xd2536250  0xd25499fc   Yes 
/tmp/opt/freeware/lib/gcc/powerpc-ibm-aix6.1.0.0/4.8.5/libgcc_s.a(shr.o)
0xd0566c80  0xd0566db6  Yes    (*)        /tmp/usr/lib/librtl.a(shr.o)
0xd010c880  0xd049b13d  Yes    (*)        /tmp/usr/lib/libc.a(shr.o)
0xd2fd7150   0xd2fd78e1   Yes               /tmp/home/sysroot/libTest.so
(*): Shared library is missing debugging information.
(gdb) bt
#0  0xd013a820 in raise () from /tmp/usr/lib/libc.a(shr.o)
#1  0xd01b3088 in abort () from /tmp/usr/lib/libc.a(shr.o)
#2  0xd2fd749c in func () from /tmp/home/sysroot/libTest.so
#3  0x100003fc in main () at main.c:8
(gdb)


Please review and let me know the comments.



Thanks & Regards,
-Sangamesh
AIX BOS Development

[-- Attachment #2: ChangeLog --]
[-- Type: application/octet-stream, Size: 120 bytes --]

	*solib-aix.c (solib_aix_bfd_open): Recognise sysroot path if a program on AIX
	 requires shared library archives (.a).

[-- Attachment #3: set_sysroot.patch --]
[-- Type: application/octet-stream, Size: 1197 bytes --]

--- ./gdb/solib-aix.c.sysroot   2016-02-09 21:19:39.000000000 -0600
+++ ./gdb/solib-aix.c   2016-09-13 02:21:22.000000000 -0500
@@ -642,17 +642,28 @@
 
      FIXME: This is a little hacky.  Perhaps we should provide access
      to the solib's lm_info here?  */
-  const int path_len = strlen (pathname);
+  int path_len = strlen (pathname);
   char *sep;
   char *filename;
   int filename_len;
-  char *member_name;
+  char *member_name, *sys_path;
   bfd *archive_bfd, *object_bfd;
   struct cleanup *cleanup;
 
-  if (pathname[path_len - 1] != ')')
+  if (pathname[path_len - 1] != ')') /* .so case */
     return solib_bfd_open (pathname);
 
+  /* If gdb_sysroot is set via set sysroot command, 
+     then we need to prefix gdb_sysroot to shared library path  */
+  /* .a shared library archives case */
+  if (gdb_sysroot != NULL && *gdb_sysroot != 0) {
+      sys_path = alloca (sizeof(gdb_sysroot)+strlen(pathname)); 
+      memset (sys_path, 0, sizeof(sys_path));
+      strcpy(sys_path, gdb_sysroot);
+      pathname = strcat (sys_path, pathname);
+  }
+  path_len = strlen (pathname);
+
   /* Search for the associated parens.  */
   sep = strrchr (pathname, '(');
   if (sep == NULL)

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

end of thread, other threads:[~2016-10-14 13:13 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <OFBAE0EEF6.511F8BA2-ON6525802D.00305F69-6525802D.0031DA2D@LocalDomain>
2016-09-27 11:39 ` set sysroot command on AIX has no effect Sangamesh Mallayya
2016-09-13  9:05 Sangamesh Mallayya
2016-09-29 15:33 ` Ulrich Weigand
2016-09-30 14:15   ` Sangamesh Mallayya
2016-09-30 14:38     ` Ulrich Weigand
2016-10-04 13:19       ` Sangamesh Mallayya
2016-10-07 19:31         ` Ulrich Weigand
2016-10-08 13:15           ` Sangamesh Mallayya
2016-10-08 14:38             ` Ulrich Weigand
2016-10-10 12:11               ` Sangamesh Mallayya
2016-10-10 16:29                 ` Ulrich Weigand
2016-10-11  7:17                   ` Ulrich Weigand
2016-10-13 13:42                     ` Sangamesh Mallayya
2016-10-13 14:03                       ` Ulrich Weigand
2016-10-13 17:44                         ` Sangamesh Mallayya
2016-10-14 13:13                           ` Ulrich Weigand

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).