[Crash-utility] [PATCH] build sial with TARGET_CFLAGS

Dave Anderson anderson at redhat.com
Tue Mar 27 18:34:21 UTC 2012



----- Original Message -----
> 
> 
> ----- Original Message -----
> >
> >
> > ----- Original Message -----
> > > ACK.
> > > This is the correct flow for these options.
> > > If someone targeting ppc64 can verify that would be great.
> >
> > I'll provision a ppc64 machine and verify the patch for both
> > 64- and 32-bit builds.  Presuming that works, queued for
> > crash-6.0.6.
> >
> > Thanks,
> >   Dave
> 
> Well, as luck would have it, this patch does not work with 32-bit
> PPC:
> 
> $ make extensions
> gcc -Wall -nostartfiles -shared -rdynamic -o dminfo.so dminfo.c -fPIC
> -DPPC -m32 -D_FILE_OFFSET_BITS=64 -fPIC -DGDB_7_3_1
> gcc -Wall -nostartfiles -shared -rdynamic -o echo.so echo.c -fPIC
> -DPPC -m32 -D_FILE_OFFSET_BITS=64 -fPIC -DGDB_7_3_1
> cd libsial && make
> bison -psial -v -t -d sial.y
> sial.y: conflicts: 252 shift/reduce, 20 reduce/reduce
> cc -O3 -g -fPIC -m32 -D_FILE_OFFSET_BITS=64 -fPIC   -c -o sial_util.o
> sial_util.c
> cc -O3 -g -fPIC -m32 -D_FILE_OFFSET_BITS=64 -fPIC   -c -o sial_node.o
> sial_node.c
> cc -O3 -g -fPIC -m32 -D_FILE_OFFSET_BITS=64 -fPIC   -c -o sial_var.o
> sial_var.c
> cc -O3 -g -fPIC -m32 -D_FILE_OFFSET_BITS=64 -fPIC   -c -o sial_func.o
> sial_func.c
> cc -O3 -g -fPIC -m32 -D_FILE_OFFSET_BITS=64 -fPIC   -c -o sial_str.o
> sial_str.c
> cc -O3 -g -fPIC -m32 -D_FILE_OFFSET_BITS=64 -fPIC   -c -o sial_op.o
> sial_op.c
> cc -O3 -g -fPIC -m32 -D_FILE_OFFSET_BITS=64 -fPIC   -c -o sial_num.o
> sial_num.c
> cc -O3 -g -fPIC -m32 -D_FILE_OFFSET_BITS=64 -fPIC   -c -o sial_stat.o
> sial_stat.c
> cc -O3 -g -fPIC -m32 -D_FILE_OFFSET_BITS=64 -fPIC   -c -o
> sial_builtin.o sial_builtin.c
> cc -O3 -g -fPIC -m32 -D_FILE_OFFSET_BITS=64 -fPIC   -c -o sial_type.o
> sial_type.c
> cc -O3 -g -fPIC -m32 -D_FILE_OFFSET_BITS=64 -fPIC   -c -o sial_case.o
> sial_case.c
> cc -O3 -g -fPIC -m32 -D_FILE_OFFSET_BITS=64 -fPIC   -c -o sial_api.o
> sial_api.c
> cc -O3 -g -fPIC -m32 -D_FILE_OFFSET_BITS=64 -fPIC   -c -o
> sial_member.o sial_member.c
> cc -O3 -g -fPIC -m32 -D_FILE_OFFSET_BITS=64 -fPIC   -c -o
> sial_alloc.o sial_alloc.c
> cc -O3 -g -fPIC -m32 -D_FILE_OFFSET_BITS=64 -fPIC   -c -o
> sial_define.o sial_define.c
> cc -O3 -g -fPIC -m32 -D_FILE_OFFSET_BITS=64 -fPIC   -c -o
> sial_input.o sial_input.c
> cc -O3 -g -fPIC -m32 -D_FILE_OFFSET_BITS=64 -fPIC   -c -o
> sial_print.o sial_print.c
> bison -psialpp -v -t -d sialpp.y
> sialpp.y: conflicts: 23 shift/reduce
> cc -O3 -g -fPIC -m32 -D_FILE_OFFSET_BITS=64 -fPIC -c sialpp.tab.c
> cc -O3 -g -fPIC -m32 -D_FILE_OFFSET_BITS=64 -fPIC -c sial.tab.c
> flex -L -Psial -t sial.l > lex.sial.c
> cc -O3 -g -fPIC -m32 -D_FILE_OFFSET_BITS=64 -fPIC -c lex.sial.c
> flex -Psialpp -t sialpp.l  > lex.sialpp.c
> cc -O3 -g -fPIC -m32 -D_FILE_OFFSET_BITS=64 -fPIC -c lex.sialpp.c
> cc -O3 -g -fPIC -m32 -D_FILE_OFFSET_BITS=64 -fPIC -o mkbaseop
> mkbaseop.c
> ./mkbaseop > baseops.c
> cc -O3 -g -fPIC -m32 -D_FILE_OFFSET_BITS=64 -fPIC -c baseops.c
> ar ccurl libsial.a sial_util.o sial_node.o sial_var.o sial_func.o
> sial_str.o sial_op.o sial_num.o sial_stat.o sial_builtin.o
> sial_type.o sial_case.o sial_api.o sial_member.o sial_alloc.o
> sial_define.o sial_input.o sial_print.o sialpp.tab.o sial.tab.o
> lex.sial.o lex.sialpp.o baseops.o
> gcc -g -I.. -Ilibsial -I../gdb-7.3.1/bfd -I../gdb-7.3.1/include
> -I../gdb-7.3.1/gdb -I../gdb-7.3.1/gdb/config
> -I../gdb-7.3.1/gdb/common -I../gdb-7.3.1 -nostartfiles -shared
> -rdynamic -o sial.so sial.c -fPIC -DPPC -m32 -D_FILE_OFFSET_BITS=64
> -fPIC -DGDB_7_3_1 -Llibsial -lsial
> sial.c:997:2: error: #error sial: Unkown ABI
> sial.c: In function ‘_init’:
> sial.c:1004: error: ‘SIAL_ABI’ undeclared (first use in this
> function)
> sial.c:1004: error: (Each undeclared identifier is reported only once
> sial.c:1004: error: for each function it appears in.)
> make[4]: [sial.so] Error 1 (ignored)
> gcc -Wall -I. -nostartfiles -shared -rdynamic -o snap.so snap.c -fPIC
> -DPPC -m32 -D_FILE_OFFSET_BITS=64 -fPIC -DGDB_7_3_1
> gcc -Wall -nostartfiles -shared -rdynamic -o trace.so trace.c -fPIC
> -DPPC -m32 -D_FILE_OFFSET_BITS=64 -fPIC -DGDB_7_3_1
> $
> 
> I don't suppose it's as easy as just adding an ABI_PPC #define here
> in sial_api.h:
> 
>  /* abi values */
>  #define ABI_MIPS        1
>  #define ABI_INTEL_X86   2
>  #define ABI_INTEL_IA    3
>  #define ABI_S390        4
>  #define ABI_S390X       5
>  #define ABI_PPC64       6
> 
> and setting SIAL_ABI to it here in sial.c?:
> 
>  #ifdef i386
>  #define SIAL_ABI  ABI_INTEL_X86
>  #else
>  #ifdef __ia64__
>  #define SIAL_ABI  ABI_INTEL_IA
>  #else
>  #ifdef __x86_64__
>  #define SIAL_ABI  ABI_INTEL_IA
>  #else
>  #ifdef __s390__
>  #define SIAL_ABI  ABI_S390
>  #else
>  #ifdef __s390x__
>  #define SIAL_ABI  ABI_S390X
>  #else
>  #ifdef PPC64
>  #define SIAL_ABI  ABI_PPC64
>  #else
>  #error sial: Unkown ABI
>  #endif
>  #endif
>  #endif
>  #endif
>  #endif
>  #endif
> 
> And I'm not mistaken, SIAL_ABI is pretty much useless.  Aside
> from getting #define'd above, it's only used here:
> 
>   sial_apiset(&icops, SIAL_ABI, sizeof(long ), 0);
> 
> and that function apparently ignores it entirely:
> 
>   void
>   sial_apiset(apiops *o, int abi, int nbpw, int sign)
>   {
>   def_t *dt;
> 
>         sial_ops=o?o:&nullops;
>         sial_setdefbtype(nbpw, sign);
>         /* get the pre defines and push them. */
>         dt=API_GETDEFS();
>         while(dt) {
> 
>                 sial_newmac(dt->name, dt->val, 0, 0, 1);
>                 dt=dt->next;
>         }
>         /* add the sial define */
>         sial_newmac(sial_strdup("sial"), sial_strdup("1"), 0, 0, 1);
>   }
> 
> Or am I missing something?
> 
> But if I do add a new ABI_PPC #define, it builds, and shows this:
> 
>   # file ./extensions/snap.so
>   ./extensions/snap.so: ELF 32-bit MSB shared object, PowerPC or
>   cisco 4500, version 1 (SYSV), dynamically linked, with unknown
>   capability 0x41000000 = 0x13676e75, with unknown  capability
>   0x10000 = 0xb0401, not stripped
>   #
> 
> whereas the native PPC64 version shows this:
> 
>  # file extensions/sial.so
>  extensions/sial.so: ELF 64-bit MSB shared object, 64-bit PowerPC or
>  cisco 7500, version 1 (SYSV), dynamically linked, not stripped
>  #
> 
> And it doesn't load the 32-bit version:
> 
>   crash> extend sial.so
>   extend: ./extensions/sial.so: not an ELF format object file
>   crash>
> 
> But that is probably a crash issue, because *none* of the extension
> modules built as 32-bit PPC objects will load:
> 
>   crash> extend snap.so
>   extend: ./extensions/snap.so: not an ELF format object file
>   crash> extend echo.so
>   extend: ./extensions/echo.so: not an ELF format object file
>   crash>
> 
> And "file" shows the additional baggage for them as well:
> 
>   # file extensions/snap.so
>   extensions/snap.so: ELF 32-bit MSB shared object, PowerPC or cisco
>   4500, version 1 (SYSV), dynamically linked, with unknown
>   capability 0x41000000 = 0x13676e75, with unknown capability
>   0x10000 = 0xb0401, not stripped
>   #
> 
> So anyway, I'm going to leave the patch in place, wait for your
> answer re: creating an API_PPC #define, and also look into the
> reason behind the load failure.

The load failure is a crash issue -- there was no EM_PPC case statement
existing in the is_shared_object() function.  With that put in place, the
32-bit PPC extension modules can be loaded, and with the "ABI_PPC" patched
version sial_api.h and sial.c in place, the module loads OK:

  crash> !file extensions/sial.so
  extensions/sial.so: ELF 32-bit MSB shared object, PowerPC or cisco 4500, version 1 (SYSV), dynamically linked, with unknown capability 0x41000000 = 0x13676e75, with unknown capability 0x10000 = 0xb0401, not stripped
  crash> extend sial.so
  Core LINUX_RELEASE == '3.2.0-rc3'
  < Sial interpreter version 3.0 >
          Loading sial commands from /usr/share/sial/crash:/root/.sial .... Done.
  ./extensions/sial.so: shared object loaded
  crash> 

So the question is whether the (useless?) API_PPC #define can
safely be added?

Thanks,
  Dave
 

  




More information about the Crash-utility mailing list