10 Replies Latest reply: Jun 24, 2014 5:49 PM by Darryl Gove-Oracle RSS

    Compilation (link) error for Shade Cachesim5 simulator

    mzaman2013

      Hello,

      I am trying to compile the shade cachesim5 simulator under 64 bit SPARC machine using Solarisstudio 12.3.

       

      When I run "make" on the makefile, I first get the following error:

      make

      cc -I../../../inc -O -DSPIX_ADDR=64  -Wl,-M,../../../lib/mapfile -o cachesim5 cachesim5.o ../../../lib/libshade.a  ../../../lib/libspix_sparc.a

      ld: fatal: ../../../lib/mapfile: 26: segment address or length 'v0x0000000200010100' exceeds internal limit

      *** Error code 2

      make: Fatal error: Command failed for target `cachesim5'

      Next I went to the ../../../lib/mapfile (see below) and (almost randomly) changed the "text=  V0x000000020001100"

      5  # This linker mapfile specifies the starting text address for Shade

           6  # analyzers.  This address is chosen to typically place the analyzer at a

           7  # location that does not conflict with the application when the application

           8  # is loaded with -benchmem=0.

           9  #

          10  # Beware, there is some tricky stuff going on here to avoid some

          11  # undesirable linker behavior.  The first line below is needed to force

          12  # the linker to properly align the sections in the text segment.  This line

          13  # starts the text segment with a special 256-byte aligned section, forcing

          14  # the text segment to start at offset 0x100 in the executable file.  The

          15  # starting address of the text segment must match this offset to ensure that

          16  # things remain properly aligned.  Therefore, the starting text address must

          17  # be chosen to satisfy this equation:

          18  #

          19  #       text_start mod pagesize = 0x100

          20  #

          21  # Since the page size is 0x1000, the bottom three hex digits of the starting

          22  # text segment address should always be 0x100 to preserve proper alignment.

          23  #

          24

          25  text | shd_algn;

          26  text = V0x0000000200010100;

      Now, that error is gone, but getting some linker error:

       

      > make

      cc -I../../../inc -O -DSPIX_ADDR=64  -Wl,-M,../../../lib/mapfile -o cachesim5 cachesim5.o ../../../lib/libshade.a  ../../../lib/libspix_sparc.a

      ld: warning: file ../../../lib/libshade.a(if_lockmem.o): wrong ELF class: ELFCLASS64

      ld: warning: file ../../../lib/libspix_sparc.a(ITYPES.o): wrong ELF class: ELFCLASS64

      Undefined                       first referenced

      symbol                             in file

      shade_appstatus                     cachesim5.o

      main                                /opt/solarisstudio12.3/prod/lib/crt1.o

      shade_print_opt_info                cachesim5.o

      shade_trsize                        cachesim5.o

      shade_malloc                        cachesim5.o

      shade_getoptv                       cachesim5.o

      spix_sparc_iop_memsize              cachesim5.o

      shade_iset_newclass                 cachesim5.o

      shade_run                           cachesim5.o

      shade_tset_new                      cachesim5.o

      shade_trctl                         cachesim5.o

      shade_usage                         cachesim5.o

      shade_error                         cachesim5.o

      spix_sparc_iop_istype               cachesim5.o

      shade_fp                            cachesim5.o

      ld: fatal: symbol referencing errors. No output written to cachesim5

      *** Error code 2

      make: Fatal error: Command failed for target `cachesim5'

      Can someone help please.....:-(

        • 1. Re: Compilation (link) error for Shade Cachesim5 simulator
          Fedor-Oracle

          > wrong ELF class: ELFCLASS64

           

          You are trying to link 64-bit objects using 32-bit link line.

          Most likely your original problem with mapfile is also 32-vs-64 bit related.

           

          When linking you should use pretty much the same code-generation options that you used during compilation

          In this case your link line lacks -m64.

           

          regards,

            Fedor.

          • 2. Re: Compilation (link) error for Shade Cachesim5 simulator
            mzaman2013

            Thanks Fedor.

            Just to be clear, the SHADE folder has 2 options. one for 32 bit and another for 64 bit. The mapfile in the 32 bit library is:

                      text_start mod pagesize = 0x100

                20  #

                21  # Since the page size is 0x1000, the bottom three hex digits of the starting

                22  # text segment address should always be 0x100 to preserve proper alignment.

                23  #

                24

                25  text | shd_algn;

                26  text = V0x10010100;

             

            I am going to try the -m64 option while compiling now. Although when i ran the "file /sam-t1/devtools/64/shade/lib/libshade.a" it gives:

            libshade.a: current ar archive, 32-bit symbol table

             

            /sam-t1/devtools/64/shade/eg/shade/cachesim5: vi Makefile:

               

                 5  # This makefile builds the 'cachesim5' analyzer.  See the cachesim5(1sh)

                 6  # manpage for information on using this analyzer.

                 7  #

                 8

                 9  OBJ  = cachesim5.o

                10  TARG = cachesim5

                11

                12  SHADEKIT = ../../..

                13

                14  LIBS       = $(SHADEKIT)/lib/libshade.a \

                15                           $(SHADEKIT)/lib/libspix_sparc.a

                16  MAPFILE    = $(SHADEKIT)/lib/mapfile

                17

                18  INC     = -I$(SHADEKIT)/inc

                19  OPT     = -O

                20  DEFS    = -DSPIX_ADDR=64 $(ARCH_DEFS)

                21  CFLAGS  = $(INC) $(OPT) $(DEFS)

                22  LDFLAGS = -Wl,-M,$(MAPFILE)

                23

                24

                25  build: $(TARG)

                26

                27  $(TARG): $(OBJ) $(LIBS) $(MAPFILE)

                28          $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $(OBJ) $(LIBS)

                29

                30

                31  clean:

                32          rm -f $(OBJ)

                33

                34  clobber: clean

                35          rm -f $(TARG)

             

            I am assuming I need to use the "-m64" flag under "CFLAGS".


            Also, the other errors of undefined symbols, are they related to this same issue you think?

             

            Thanks

            • 3. Re: Compilation (link) error for Shade Cachesim5 simulator
              mzaman2013

              I just ran with "-m64" option in the CFLAGS, and get the following error:

              > make

              cc -I../../../inc -O -DSPIX_ADDR=64  -m64 -Wl,-M,../../../lib/mapfile -o cachesim5 cachesim5.o ../../../lib/libshade.a  ../../../lib/libspix_sparc.a

              ld: fatal: file cachesim5.o: wrong ELF class: ELFCLASS32

              ld: fatal: file processing errors. No output written to cachesim5

              *** Error code 2

              make: Fatal error: Command failed for target `cachesim5'

              • 4. Re: Compilation (link) error for Shade Cachesim5 simulator
                Steve.Clamage-Oracle

                You have a mix of 32-bit and 64-bit binaries for this application. Sometimes makefiles have separate targets and separate target directories for the two modes. If not, leftover binaries of the wrong mode won't be rebuilt, leaving you with a mix that won't link.

                 

                There should be a "make" target that removes everything. Do that. If you added a -m32 or -m64 option to any makefiles, remove those changes. Then rebuild everything using the makefile defaults, which ought to be consistent.

                • 5. Re: Compilation (link) error for Shade Cachesim5 simulator
                  mzaman2013

                  Hello Steve,

                  in that folder there is only the Makefile and cachesim.c; there is no other makefiles.

                   

                  Also, there is a bin folder where I have the pre-compiled binary "cachesim5" which says:

                   

                  "file /sam-t1/devtools/64/shade/bin"

                   

                  cachesim5: 
                  ELF 64-bit MSB executable SPARCV9 Version 1, UltraSPARC1 Extensions Required, dynamically linked, not stripped

                   

                  Now, when I tried to just run that binary, i get the following error:

                  ./cachesim5

                  ld.so.1: cachesim5: fatal: relocation error: file cachesim5: symbol _lwp_makecontext: referenced symbol not found

                  Killed

                  I am not sure what is meant by "make" target that removes everything. :-(

                   

                  apology in advance for any novice/amateurish question.

                   

                  Thanks

                  • 6. Re: Compilation (link) error for Shade Cachesim5 simulator
                    Steve.Clamage-Oracle

                    What do you mean by "precompiled binary"? Did you download it from the web site, as opposed to building it yourself? If someone else built it, you need to know what version of of Solaris it was built on, and you need to have the same version or a more recent version of Solaris. You didn't mention what Solaris you are using. To find out, run the command

                        uname -a

                     

                     

                    The missing symbol when  you try to run the program means one or both of the following:

                    - You are running on an earlier version of Solaris that is missing interfaces that the later version has.

                    - The program was built without a dependency on a library that it needs.

                     

                     

                    The makefile you show is remarkably brief. It uses two archive libraries from SHADEKIT that it does not build. Did you run a separate build in SHADEKIT before trying to build cachesim5, or were the binaries downloaded from the web site?

                     

                     

                    The makefile defines a local macro

                    DEFS    = -DSPIX_ADDR=64 $(ARCH_DEFS)

                    but does not define ARCH_DEFS, meaning you get only SPIX_ADDR set to 64.

                    That sounds suspiciously like it wants a 64-bit build, and ARCH_DEFS should specify -m64.

                    ARCH_DEFS = -m64

                    (Or you could just add -m64 to CFLAGS.)

                     

                    But then you have to build the archive libraries libshade.a and libspix_sparc.a with -m64 as well.

                     

                     

                    The makefile has 3 targets: build, clean, and clobber. Since build is listed first, running plain "make" will use that target. You can remove everything that the makefile builds by specifying the target "clobber":

                        make clobber

                    Since this makefile does not build the SHADEKIT binaries, it won't remove them.

                    • 7. Re: Compilation (link) error for Shade Cachesim5 simulator
                      Darryl Gove-Oracle

                      Hi,

                       

                      My usage of shade is from a few years back. IIRC shade was not supported on anything past Solaris 9 - the threading model changed in S10 and the APIs changed.

                       

                      Darryl.

                      • 8. Re: Compilation (link) error for Shade Cachesim5 simulator
                        mzaman2013

                        I downloaded this package from the Opensparc T-1 website (OpenSPARC T1 Processor for Architecture and Performance Modeling Tools). After the package is downloaded, in the "sam-t1/devtools/64/shade/bin" has the buitlin (pre-compiled) binaries. Also, the source code for these binaries are available at "../eg/shade/". The "cachesim5.c and Makefile" are in this folder and I was trying to compile the cachesim5 from here (if i can compile it, then I could make any change necessary and recompile to my needs).


                        I am on solaris 10 SPARC machine.

                        uname -a

                        SunOS ee58110 5.10 Generic_147440-01 sun4u sparc SUNW,Sun-Blade-2500

                        I did no compilation on the $SHADEKIT folder.

                         

                        I just read some documents in the folder "SPIX_FAQ.txt" which mentions about  the SPIX v5 and SPIX v6:

                        Q3: Where can I find it?

                            34

                            35  A3: Spix5

                            36          /import/shade/v5/stable/spixtools.v9.elf/lib/libspix.a (32bit library)

                            37          /import/shade/v5/stable/spixtools.v9.elf/src/include/  (includes)

                            38

                            39      Spix6

                            40          /import/shade/v6/stable-32/lib/libspix_sparc.a  (32bit library)

                            41          /import/shade/v6/stable-32/inc                  (includes)

                            42          /import/shade/v6/stable-64/lib/libspix_sparc.a  (64bit library)

                            43          /import/shade/v6/stable-64/inc                  (includes)

                            44

                        I guess I need to port the SPIX5 stuff to Spix6 (assuming that is the only way to do it). But which bring the question, why would they include something in the package which is not working. :-( (Or maybe i might be completely wrong with the procedure).

                         

                        Appreciate your help.

                         



                        • 9. Re: Compilation (link) error for Shade Cachesim5 simulator
                          mzaman2013

                          Darryl,

                          Thanks for the info.

                          There is a porting_guide.txt document inside the folder which talks about porting (!!!) the Spix5 to Spix6.

                           

                          Will that help to run this on solaris 10?

                           

                          Thanks

                          • 10. Re: Compilation (link) error for Shade Cachesim5 simulator
                            Darryl Gove-Oracle

                            Hi,

                             

                            I don't think so. I've not looked into what's needed. It might be some simple changes. The minimal changes that would be needed would be some definitions for the missing functions - some sort of shim to translate them to functions that exist in S10. But I've no idea whether that's feasible.

                             

                            Darryl.