Loading ...
Sorry, an error occurred while loading the content.

Re: Linker question

Expand Messages
  • Jefferson Smith
    Have you tried removing it? I have never needed to add libgcc to my commandline, although I usually link it with gcc which should call ld with the right
    Message 1 of 12 , May 2, 2005
    • 0 Attachment
      Have you tried removing it? I have never needed to add libgcc to my
      commandline, although I usually link it with 'gcc' which should call
      'ld' with the right parameters.

      Otherwise, you might need to add a search path for 'ld'... was it "-L"?

      --- In gnu-m68hc11@yahoogroups.com, "jlarada1975" <jhamed@w...> wrote:
      > Hello,
      >
      > I just starting using the gnu compiler. I started with the
      > blinky.zip example on Karl Lunt's site.
      >
      > Specific question:
      >
      > The makefile (blinky.mak) is not working as the linker can not find
      > the correct library file ( -lgcc):
      >
      > ARCHIVES = -lgcc
      > ...
      > all: $(OBJS)
      > $(LD) -T$(NAME).ld $(LFLAGS) -o$(NAME).obj $(OBJS) $(ARCHIVES)
      >
      > I am using the following:
      > gnu-68hc1x-2.2.exe
      > (Release 2.2, 11002KB, Snapshot 20030501)
      >
      > Thanks in advance.
    • jlarada1975
      Yes I have. When I do, I get the following errors. Thanks for ... C: c make -f blinky.mak c:/usr/bin/m6811-elf-ld -Tblinky.ld -Map blinky.map -oblinky.obj
      Message 2 of 12 , May 2, 2005
      • 0 Attachment
        Yes I have. When I do, I get the following errors. Thanks for
        asking:
        ----------------------------------------------------------------
        C:\c>make -f blinky.mak
        c:/usr/bin/m6811-elf-ld -Tblinky.ld -Map blinky.map -oblinky.obj
        blinky.o crt0.o
        isr.o vectors.o
        c:/usr/bin/m6811-elf-ld: crt0.o: linking files compiled for 16-bit
        integers (-ms
        hort) and others for 32-bit integers
        Bad value: failed to merge target specific data of file crt0.o
        blinky.o: undefined reference to `memcpy'
        make: *** [all] Error 1
        ------------------------------------------------------------------

        --- In gnu-m68hc11@yahoogroups.com, "Jefferson Smith"
        <imajeffs@h...> wrote:
        > Have you tried removing it? I have never needed to add libgcc to my
        > commandline, although I usually link it with 'gcc' which should
        call
        > 'ld' with the right parameters.
        >
        > Otherwise, you might need to add a search path for 'ld'... was
        it "-L"?
        >
        > --- In gnu-m68hc11@yahoogroups.com, "jlarada1975" <jhamed@w...>
        wrote:
        > > Hello,
        > >
        > > I just starting using the gnu compiler. I started with the
        > > blinky.zip example on Karl Lunt's site.
        > >
        > > Specific question:
        > >
        > > The makefile (blinky.mak) is not working as the linker can not
        find
        > > the correct library file ( -lgcc):
        > >
        > > ARCHIVES = -lgcc
        > > ...
        > > all: $(OBJS)
        > > $(LD) -T$(NAME).ld $(LFLAGS) -o$(NAME).obj $(OBJS)
        $(ARCHIVES)
        > >
        > > I am using the following:
        > > gnu-68hc1x-2.2.exe
        > > (Release 2.2, 11002KB, Snapshot 20030501)
        > >
        > > Thanks in advance.
      • Stephane Carrez
        ... Hash: SHA1 ... Use m6811-elf-gcc for the link. Using the linker directly is more complex and requires passing the *correct* options, search paths and
        Message 3 of 12 , May 9, 2005
        • 0 Attachment
          -----BEGIN PGP SIGNED MESSAGE-----
          Hash: SHA1

          jlarada1975 wrote:
          > Hello,
          >
          > I just starting using the gnu compiler. I started with the
          > blinky.zip example on Karl Lunt's site.
          >
          > Specific question:
          >
          > The makefile (blinky.mak) is not working as the linker can not find
          > the correct library file ( -lgcc):
          >
          > ARCHIVES = -lgcc
          > ...
          > all: $(OBJS)
          > $(LD) -T$(NAME).ld $(LFLAGS) -o$(NAME).obj $(OBJS) $(ARCHIVES)
          >
          > I am using the following:
          > gnu-68hc1x-2.2.exe
          > (Release 2.2, 11002KB, Snapshot 20030501)
          >
          > Thanks in advance.
          >

          Use m6811-elf-gcc for the link.

          Using the linker directly is more complex and requires passing the
          *correct* options, search paths and libraries. The m6811-elf-gcc is
          a driver that takes care of this.

          You must pass the *same* compilation flags during the link (ie, CFLAGS).
          Even if you think they are not used, *they are*.

          > c:/usr/bin/m6811-elf-ld: crt0.o: linking files compiled for 16-bit
          > integers (-ms
          > hort) and others for 32-bit integers
          > Bad value: failed to merge target specific data of file crt0.o

          This is what happens when you link by hand and don't use the correct
          crt0 or library.

          http://m68hc11.serveftp.org/faq.php?file=faq/link/link-error-1.txt


          I suggest you *always* use the following scheme:

          CFLAGS=-Os -mshort -m68hc11 # or -m68hcs12
          CC=m6811-elf-gcc

          all: $(OBJS)
          $(CC) -Wl,-T$(NAME).ld $(CFLAGS) $(LDFLAGS) -o $(NAME).obj $(OBJS)
          $(ARCHIVES)

          If you need to pass specific options to the linker, use the following form:

          - -Wl,<linker-option>


          Stephane
          -----BEGIN PGP SIGNATURE-----
          Version: GnuPG v1.2.4 (GNU/Linux)
          Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org

          iD8DBQFCf72wNyQxO2LzKT0RAsElAJwPwabWXwgPrSMsElXJu4uNe8yBjACg4tW/
          e/FXoNQzGUquDpLZVGBldcQ=
          =tSav
          -----END PGP SIGNATURE-----
        • jlarada1975
          ... find ... $(ARCHIVES) ... is ... CFLAGS). ... bit ... correct ... 1.txt ... $(OBJS) ... Thanks so much for the information. It is very helpful. The reason
          Message 4 of 12 , May 9, 2005
          • 0 Attachment
            --- In gnu-m68hc11@yahoogroups.com, Stephane Carrez <stcarrez@n...>
            wrote:
            > -----BEGIN PGP SIGNED MESSAGE-----
            > Hash: SHA1
            >
            > jlarada1975 wrote:
            > > Hello,
            > >
            > > I just starting using the gnu compiler. I started with the
            > > blinky.zip example on Karl Lunt's site.
            > >
            > > Specific question:
            > >
            > > The makefile (blinky.mak) is not working as the linker can not
            find
            > > the correct library file ( -lgcc):
            > >
            > > ARCHIVES = -lgcc
            > > ...
            > > all: $(OBJS)
            > > $(LD) -T$(NAME).ld $(LFLAGS) -o$(NAME).obj $(OBJS)
            $(ARCHIVES)
            > >
            > > I am using the following:
            > > gnu-68hc1x-2.2.exe
            > > (Release 2.2, 11002KB, Snapshot 20030501)
            > >
            > > Thanks in advance.
            > >
            >
            > Use m6811-elf-gcc for the link.
            >
            > Using the linker directly is more complex and requires passing the
            > *correct* options, search paths and libraries. The m6811-elf-gcc
            is
            > a driver that takes care of this.
            >
            > You must pass the *same* compilation flags during the link (ie,
            CFLAGS).
            > Even if you think they are not used, *they are*.
            >
            > > c:/usr/bin/m6811-elf-ld: crt0.o: linking files compiled for 16-
            bit
            > > integers (-ms
            > > hort) and others for 32-bit integers
            > > Bad value: failed to merge target specific data of file crt0.o
            >
            > This is what happens when you link by hand and don't use the
            correct
            > crt0 or library.
            >
            > http://m68hc11.serveftp.org/faq.php?file=faq/link/link-error-
            1.txt
            >
            >
            > I suggest you *always* use the following scheme:
            >
            > CFLAGS=-Os -mshort -m68hc11 # or -m68hcs12
            > CC=m6811-elf-gcc
            >
            > all: $(OBJS)
            > $(CC) -Wl,-T$(NAME).ld $(CFLAGS) $(LDFLAGS) -o $(NAME).obj
            $(OBJS)
            > $(ARCHIVES)
            >
            > If you need to pass specific options to the linker, use the
            following form:
            >
            > - -Wl,<linker-option>
            >
            >
            > Stephane
            > -----BEGIN PGP SIGNATURE-----
            > Version: GnuPG v1.2.4 (GNU/Linux)
            > Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org
            >
            > iD8DBQFCf72wNyQxO2LzKT0RAsElAJwPwabWXwgPrSMsElXJu4uNe8yBjACg4tW/
            > e/FXoNQzGUquDpLZVGBldcQ=
            > =tSav
            > -----END PGP SIGNATURE-----


            Thanks so much for the information. It is very helpful. The reason
            I used a link file is because I thought I needed one. I have seen
            examples using a file called memory.x to accomplish the same thing
            but I did not know how to use that to compile and link more than one
            c language module. If anyone can point me to an example using
            memory.x and linking multiple modules, I would appreciate it.

            I am getting to like this compiler quite a bit. Thanks.
          • Jefferson Smith
            Don t worry, you can still choose to use either memory.x or a customized linker script, or both. -Wl,-T$(NAME).ld is a parameter for gcc to tell it to pass
            Message 5 of 12 , May 10, 2005
            • 0 Attachment
              Don't worry, you can still choose to use either memory.x or a
              customized linker script, or both.

              "-Wl,-T$(NAME).ld" is a parameter for gcc to tell it to pass the
              program to the linker, using whatever filename of the linker script
              defined as "$(NAME).ld". This way you can have the complete script in
              the current directory and know all that it will do.

              I often use "-Wl,-m,m68hc12elfb", which calls a built-in script. The
              script can actually be found (and even edited) in your installed
              files. Mine is "/usr/m6811-elf/lib/ldscripts/m68hc12elfb.x". Viewing
              this file shows that it requests to include "memory.x" therefore you
              have to put the required MEMORY definition in a file called "memory.x".

              Looks like your first problem though is to add the options like
              "-mshort" to all the gcc commands so it doesn't get confused about
              your intended size of integers.

              --- In gnu-m68hc11@yahoogroups.com, "jlarada1975" <jhamed@w...> wrote:
              > Thanks so much for the information. It is very helpful. The reason
              > I used a link file is because I thought I needed one. I have seen
              > examples using a file called memory.x to accomplish the same thing
              > but I did not know how to use that to compile and link more than one
              > c language module. If anyone can point me to an example using
              > memory.x and linking multiple modules, I would appreciate it.
              >
              > I am getting to like this compiler quite a bit. Thanks.

              > --- In gnu-m68hc11@yahoogroups.com, Stephane Carrez <stcarrez@n...>
              > wrote:

              > > I suggest you *always* use the following scheme:
              > >
              > > CFLAGS=-Os -mshort -m68hc11 # or -m68hcs12
              > > CC=m6811-elf-gcc
              > >
              > > all: $(OBJS)
              > > $(CC) -Wl,-T$(NAME).ld $(CFLAGS) $(LDFLAGS) -o $(NAME).obj
              > $(OBJS)
              > > $(ARCHIVES)
              > >
              > > If you need to pass specific options to the linker, use the
              > following form:
              > >
              > > - -Wl,<linker-option>
            • jlara6812
              Hello, I began using the toolchain a couple of months ago and I am struggling with some of the aspects: 1) I am using a linker file and m6811-elf-ld.exe
              Message 6 of 12 , Jun 12, 2005
              • 0 Attachment
                Hello,

                I began using the toolchain a couple of months ago and I am struggling
                with some of the aspects:

                1) I am using a linker file and m6811-elf-ld.exe instead of linking by
                using m6811-elf-gcc.exe. Is it possible to create the same .elf
                and .dmp files similar to what is created in the hello12gnu.zip
                example that comes with the toolchain? I tried but was not successful
                in creating them.

                2) I am confused why it is possible to link in two ways:
                one by using m6811-elf-ld and the other by using m6811-elf-gcc. I
                have used other compilers such as IAR, Cosmic, and Metrowerks and have
                always used a linker to link the files.

                Thanks in advance for the help.
              • Triffid Hunter
                gcc does c - preprocess - asm - object - link - output elf, unless you tell it to do otherwise.
                Message 7 of 12 , Jun 13, 2005
                • 0 Attachment
                  gcc does c -> preprocess -> asm -> object -> link -> output elf, unless you tell it to do otherwise.

                  jlara6812 wrote:
                  > Hello,
                  >
                  > I began using the toolchain a couple of months ago and I am struggling
                  > with some of the aspects:
                  >
                  > 1) I am using a linker file and m6811-elf-ld.exe instead of linking by
                  > using m6811-elf-gcc.exe. Is it possible to create the same .elf
                  > and .dmp files similar to what is created in the hello12gnu.zip
                  > example that comes with the toolchain? I tried but was not successful
                  > in creating them.
                  >
                  > 2) I am confused why it is possible to link in two ways:
                  > one by using m6811-elf-ld and the other by using m6811-elf-gcc. I
                  > have used other compilers such as IAR, Cosmic, and Metrowerks and have
                  > always used a linker to link the files.
                  >
                  > Thanks in advance for the help.
                  >
                  >
                  >
                  >
                  >
                  >
                  >
                  > To Post a message, send it to: gnu-m68hc11@...
                  >
                  > To Unsubscribe, send a blank message to: gnu-m68hc11-unsubscribe@...
                  > Yahoo! Groups Links
                  >
                  >
                  >
                  >
                  >
                  >
                  >
                • Jefferson Smith
                  ... All this is possible if you understand how it works. You might want to try asking some specific questions so someone can get a feel of your understanding
                  Message 8 of 12 , Jun 13, 2005
                  • 0 Attachment
                    --- In gnu-m68hc11@yahoogroups.com, "jlara6812" <jlara6812@y...> wrote:
                    > Hello,
                    >
                    > I began using the toolchain a couple of months ago and I am struggling
                    > with some of the aspects:
                    >
                    > 1) I am using a linker file and m6811-elf-ld.exe instead of linking by
                    > using m6811-elf-gcc.exe. Is it possible to create the same .elf
                    > and .dmp files similar to what is created in the hello12gnu.zip
                    > example that comes with the toolchain? I tried but was not successful
                    > in creating them.

                    All this is possible if you understand how it works. You might want to
                    try asking some specific questions so someone can get a feel of your
                    understanding so far.


                    >
                    > 2) I am confused why it is possible to link in two ways:
                    > one by using m6811-elf-ld and the other by using m6811-elf-gcc. I
                    > have used other compilers such as IAR, Cosmic, and Metrowerks and have
                    > always used a linker to link the files.
                    >
                    > Thanks in advance for the help.

                    You are confused because you are thinking there are two linking
                    programs. GCC does not link. The reason it can call ld for you is
                    because it already knows complex parameters that may need passed to ld
                    for your desired result.

                    The reason this all seems so different from the Embedded tools (i.e.
                    Metrowerks) is because GCC is not an "embedded tool". GCC was designed
                    for compiling targets to run in a Unix-like system, and not standalone
                    in a small MCU. I think it's amazing that you can do so much, but also
                    some day I hope we can use the m68hc1x port to create an actual Linux
                    system on one of these MCU families.

                    --jeffs
                  • jlara6812
                    Thanks very much for your help. This past weekend I tried creating an elf file and a dump file. I was wondering if that is possible while using the linker
                    Message 9 of 12 , Jun 13, 2005
                    • 0 Attachment
                      Thanks very much for your help.

                      This past weekend I tried creating an elf file and a dump file. I
                      was wondering if that is possible while using the linker m6811-elf-
                      ld.exe instead of m6811-elf-gcc. My commands are as follows:

                      ..\usr\bin\m6811-elf-ld -T project.ld -Map project.map -o
                      project.obj main.o crt0.o isr.o vectors.o -lgcc

                      ..\usr\bin\m6811-elf-objcopy -O srec project.obj project.s19

                      Can you please show me how to create the elf and dmp files?

                      Thanks in advance.
                    • Triffid Hunter
                      wow that s so much more involved than what i use.. i normally just go m6811-elf-gcc -o stuff stuff.c (or .s), and stuff is the elf executable output file. i
                      Message 10 of 12 , Jun 14, 2005
                      • 0 Attachment
                        wow that's so much more involved than what i use..

                        i normally just go m6811-elf-gcc -o stuff stuff.c (or .s), and 'stuff' is the elf executable output file.

                        i can then use m6811-elf-objcopy to create bin/s19 as appropriate, and m6811-elf-objdump to make dumps.. just read m6811-elf-*'s --help and --target-help ;)

                        do you have any particular reason for doing everything that gcc does automatically by hand?

                        - Triffid Hunter

                        jlara6812 wrote:
                        > Thanks very much for your help.
                        >
                        > This past weekend I tried creating an elf file and a dump file. I
                        > was wondering if that is possible while using the linker m6811-elf-
                        > ld.exe instead of m6811-elf-gcc. My commands are as follows:
                        >
                        > ..\usr\bin\m6811-elf-ld -T project.ld -Map project.map -o
                        > project.obj main.o crt0.o isr.o vectors.o -lgcc
                        >
                        > ..\usr\bin\m6811-elf-objcopy -O srec project.obj project.s19
                        >
                        > Can you please show me how to create the elf and dmp files?
                        >
                        > Thanks in advance.
                        >
                        >
                        >
                        >
                        >
                        >
                        >
                        >
                        >
                        > To Post a message, send it to: gnu-m68hc11@...
                        >
                        > To Unsubscribe, send a blank message to: gnu-m68hc11-unsubscribe@...
                        > Yahoo! Groups Links
                        >
                        >
                        >
                        >
                        >
                        >
                        >
                      • Jefferson Smith
                        I decided to try -v to tell gcc to list internal commands. I find it lists many parameters that are probably important to send to ld. Below, I think you can
                        Message 11 of 12 , Jun 14, 2005
                        • 0 Attachment
                          I decided to try -v to tell gcc to list internal commands. I find it
                          lists many parameters that are probably important to send to ld.

                          Below, I think you can find the important parameters for ld. To me,
                          however, it is better to just use a gcc switch that sends parameters
                          directly to ld when called by gcc. For example you should try
                          "-Wl,-Map,project.map" on the gcc command line.

                          Notice the secont part below. I think collect2 is the internal command
                          for linking, but ld uses the same parameters. One thing that is often
                          forgotten is the many -L search directories.

                          > m6811-elf-gcc -m68hc12 -mshort -Wl,-T,ldscript.x
                          -L../../gel/config/dragon12-ram-db12 -mrelax -Wl,-M -v -o modrx.elf
                          modrx.o LCDControl.o serialpktrx.o
                          Reading specs from /usr/lib/gcc-lib/m6811-elf/3.0.4/specs
                          Configured with: ./configure --target=m6811-elf
                          --program-prefix=m6811-elf- --enable-languages=c,c++ --prefix=/usr
                          --host=i686-linux
                          Thread model: single
                          gcc version 3.0.4 m68hc1x-20030430

                          /usr/lib/gcc-lib/m6811-elf/3.0.4/collect2 -m m68hc12elf -o modrx.elf
                          /usr/lib/gcc-lib/m6811-elf/3.0.4/m68hc12/mshort/crt1.o
                          -L../../gel/config/dragon12-ram-db12
                          -L/usr/lib/gcc-lib/m6811-elf/3.0.4/m68hc12/mshort
                          -L/usr/lib/gcc-lib/m6811-elf/3.0.4
                          -L/usr/lib/gcc-lib/m6811-elf/3.0.4/../../../../m6811-elf/lib/m68hc12/mshort
                          -L/usr/lib/gcc-lib/m6811-elf/3.0.4/../../../../m6811-elf/lib -T
                          ldscript.x -M modrx.o LCDControl.o serialpktrx.o -lgcc -lgcc
                          Archive member included because of file (symbol)
                          ...(map output continues)

                          --- In gnu-m68hc11@yahoogroups.com, "jlara6812" <jlara6812@y...> wrote:
                          > Thanks very much for your help.
                          >
                          > This past weekend I tried creating an elf file and a dump file. I
                          > was wondering if that is possible while using the linker m6811-elf-
                          > ld.exe instead of m6811-elf-gcc. My commands are as follows:
                          >
                          > ..\usr\bin\m6811-elf-ld -T project.ld -Map project.map -o
                          > project.obj main.o crt0.o isr.o vectors.o -lgcc
                          >
                          > ..\usr\bin\m6811-elf-objcopy -O srec project.obj project.s19
                          >
                          > Can you please show me how to create the elf and dmp files?
                          >
                          > Thanks in advance.
                        Your message has been successfully submitted and would be delivered to recipients shortly.