public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* modifying libgcc.a
@ 2009-01-22 18:08 Navid Toosizadeh
  2009-01-22 20:21 ` Navid Toosizadeh
  0 siblings, 1 reply; 6+ messages in thread
From: Navid Toosizadeh @ 2009-01-22 18:08 UTC (permalink / raw)
  To: gcc-help

Greetings,

For some reason, I like to modify libgcc.a after GCC is built. I intend to add new definitions for macros such as mulsi3 existing in libgcc.a. Here's what I did:

I compiled the new definition of mulsi3, made the object and then converted it to libgcc.a using "ar".

Now, to test this, I wrote a small program that multiplies two numbers. When I do "gcc test_program.c libgcc.a" it compiles and the output is correct.

But when I do : "gcc test_program.c", it throws an error complaining about undefined reference to __mulsi3, although I did put the libgcc.a in the path (and the linker doesn't complain there's no libgcc when I tried -lgcc).

Could you help e understand why the definition of __mulsi3 is not used from libgcc.a when I test "gcc test_program.c"?

Best regards
Navid



      

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

* Re: modifying libgcc.a
  2009-01-22 18:08 modifying libgcc.a Navid Toosizadeh
@ 2009-01-22 20:21 ` Navid Toosizadeh
  2009-01-22 21:01   ` Blazej
  2009-01-23 15:59   ` Ian Lance Taylor
  0 siblings, 2 replies; 6+ messages in thread
From: Navid Toosizadeh @ 2009-01-22 20:21 UTC (permalink / raw)
  To: gcc-help

Ok, I guess I have some updates on the problem below:

When I do "gcc test.program.c -lgcc", it works. Does that mean linker does not link the output of gcc with libgcc? Should I seek for the problem in gcc or in my linker? (perior to changing libgcc, I never needed to use libgcc).

Thank you
Navid



----- Original Message ----
From: Navid Toosizadeh <navid_toosizadeh@yahoo.com>
To: gcc-help@gcc.gnu.org
Sent: Thursday, January 22, 2009 1:08:06 PM
Subject: modifying libgcc.a

Greetings,

For some reason, I like to modify libgcc.a after GCC is built. I intend to add new definitions for macros such as mulsi3 existing in libgcc.a. Here's what I did:

I compiled the new definition of mulsi3, made the object and then converted it to libgcc.a using "ar".

Now, to test this, I wrote a small program that multiplies two numbers. When I do "gcc test_program.c libgcc.a" it compiles and the output is correct.

But when I do : "gcc test_program.c", it throws an error complaining about undefined reference to __mulsi3, although I did put the libgcc.a in the path (and the linker doesn't complain there's no libgcc when I tried -lgcc).

Could you help e understand why the definition of __mulsi3 is not used from libgcc.a when I test "gcc test_program.c"?

Best regards
Navid


      

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

* RE: modifying libgcc.a
  2009-01-22 20:21 ` Navid Toosizadeh
@ 2009-01-22 21:01   ` Blazej
  2009-01-22 21:13     ` Navid Toosizadeh
  2009-01-23 15:59   ` Ian Lance Taylor
  1 sibling, 1 reply; 6+ messages in thread
From: Blazej @ 2009-01-22 21:01 UTC (permalink / raw)
  To: gcc-help

>Ok, I guess I have some updates on the problem below:
>When I do "gcc test.program.c -lgcc", it works. Does that mean linker does
>not link the output of gcc with libgcc? Should I seek for the problem in
>gcc or in my linker? (perior to changing libgcc, I never needed to use
>libgcc).

>Thank you
>David

Everything is ok. The linker automatically adds the lib suffix. So when you
execute -lgcc it means either -llibgcc.a or -llibgcc.so. This depends on
what link option you choose (-static, -shared).

Regards,
Blazej



----- Original Message ----
From: Navid Toosizadeh <navid_toosizadeh@yahoo.com>
To: gcc-help@gcc.gnu.org
Sent: Thursday, January 22, 2009 1:08:06 PM
Subject: modifying libgcc.a

Greetings,

For some reason, I like to modify libgcc.a after GCC is built. I intend to
add new definitions for macros such as mulsi3 existing in libgcc.a. Here's
what I did:

I compiled the new definition of mulsi3, made the object and then converted
it to libgcc.a using "ar".

Now, to test this, I wrote a small program that multiplies two numbers. When
I do "gcc test_program.c libgcc.a" it compiles and the output is correct.

But when I do : "gcc test_program.c", it throws an error complaining about
undefined reference to __mulsi3, although I did put the libgcc.a in the path
(and the linker doesn't complain there's no libgcc when I tried -lgcc).

Could you help e understand why the definition of __mulsi3 is not used from
libgcc.a when I test "gcc test_program.c"?

Best regards
Navid


      





----------------------------------------------------------------------
Sprawdz, co wyswietlaja kina w Twoim miescie!
http://link.interia.pl/f2028

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

* Re: modifying libgcc.a
  2009-01-22 21:01   ` Blazej
@ 2009-01-22 21:13     ` Navid Toosizadeh
  2009-01-22 21:26       ` Blazej
  0 siblings, 1 reply; 6+ messages in thread
From: Navid Toosizadeh @ 2009-01-22 21:13 UTC (permalink / raw)
  To: gcc-help

Dear Blazej,

My question is why when I do "gcc test.program.c"
without -lgcc, I get the error message? Isn't linker supposed to link
the program with libgcc automatically? 

Best
Navid

 

----- Original Message ----
From: Blazej <riona@poczta.fm>
To: gcc-help@gcc.gnu.org
Sent: Thursday, January 22, 2009 4:01:02 PM
Subject: RE: modifying libgcc.a

>Ok, I guess I have some updates on the problem below:
>When I do "gcc test.program.c -lgcc", it works. Does that mean linker does
>not link the output of gcc with libgcc? Should I seek for the problem in
>gcc or in my linker? (perior to changing libgcc, I never needed to use
>libgcc).

>Thank you
>David

Everything is ok. The linker automatically adds the lib suffix. So when you
execute -lgcc it means either -llibgcc.a or -llibgcc.so. This depends on
what link option you choose (-static, -shared).

Regards,
Blazej



----- Original Message ----
From: Navid Toosizadeh <navid_toosizadeh@yahoo.com>
To: gcc-help@gcc.gnu.org
Sent: Thursday, January 22, 2009 1:08:06 PM
Subject: modifying libgcc.a

Greetings,

For some reason, I like to modify libgcc.a after GCC is built. I intend to
add new definitions for macros such as mulsi3 existing in libgcc.a. Here's
what I did:

I compiled the new definition of mulsi3, made the object and then converted
it to libgcc.a using "ar".

Now, to test this, I wrote a small program that multiplies two numbers. When
I do "gcc test_program.c libgcc.a" it compiles and the output is correct.

But when I do : "gcc test_program.c", it throws an error complaining about
undefined reference to __mulsi3, although I did put the libgcc.a in the path
(and the linker doesn't complain there's no libgcc when I tried -lgcc).

Could you help e understand why the definition of __mulsi3 is not used from
libgcc.a when I test "gcc test_program.c"?

Best regards
Navid


      





----------------------------------------------------------------------
Sprawdz, co wyswietlaja kina w Twoim miescie!
http://link.interia.pl/f2028


      

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

* RE: modifying libgcc.a
  2009-01-22 21:13     ` Navid Toosizadeh
@ 2009-01-22 21:26       ` Blazej
  0 siblings, 0 replies; 6+ messages in thread
From: Blazej @ 2009-01-22 21:26 UTC (permalink / raw)
  To: gcc-help

>Dear Blazej,

>My question is why when I do "gcc test.program.c" without -lgcc, I get the
>error message? Isn't linker supposed to link the program with libgcc
>automatically? 

>Best
>David

When you are using gcc (or using an old binary compiled with gcc) it is a
common error. In such a case you should manually enter -L and -lgcc on the
switches list. In other case you wouldn't do this. 

It's all about the linker. When you link something, the linker search
through directory list you specify (-L). It assumes that -l(library_name)
will be find there. But it doesn't work for gcc.

Thanks,
Blazej

-----Original Message-----
From: gcc-help-owner@gcc.gnu.org [mailto:gcc-help-owner@gcc.gnu.org] On
Behalf Of Navid Toosizadeh
Sent: Thursday, January 22, 2009 10:13 PM
To: gcc-help@gcc.gnu.org
Subject: Re: modifying libgcc.a

Dear Blazej,

My question is why when I do "gcc test.program.c"
without -lgcc, I get the error message? Isn't linker supposed to link
the program with libgcc automatically? 

Best
Navid

 

----- Original Message ----
From: Blazej <riona@poczta.fm>
To: gcc-help@gcc.gnu.org
Sent: Thursday, January 22, 2009 4:01:02 PM
Subject: RE: modifying libgcc.a

>Ok, I guess I have some updates on the problem below:
>When I do "gcc test.program.c -lgcc", it works. Does that mean linker does
>not link the output of gcc with libgcc? Should I seek for the problem in
>gcc or in my linker? (perior to changing libgcc, I never needed to use
>libgcc).

>Thank you
>David

Everything is ok. The linker automatically adds the lib suffix. So when you
execute -lgcc it means either -llibgcc.a or -llibgcc.so. This depends on
what link option you choose (-static, -shared).

Regards,
Blazej



----- Original Message ----
From: Navid Toosizadeh <navid_toosizadeh@yahoo.com>
To: gcc-help@gcc.gnu.org
Sent: Thursday, January 22, 2009 1:08:06 PM
Subject: modifying libgcc.a

Greetings,

For some reason, I like to modify libgcc.a after GCC is built. I intend to
add new definitions for macros such as mulsi3 existing in libgcc.a. Here's
what I did:

I compiled the new definition of mulsi3, made the object and then converted
it to libgcc.a using "ar".

Now, to test this, I wrote a small program that multiplies two numbers. When
I do "gcc test_program.c libgcc.a" it compiles and the output is correct.

But when I do : "gcc test_program.c", it throws an error complaining about
undefined reference to __mulsi3, although I did put the libgcc.a in the path
(and the linker doesn't complain there's no libgcc when I tried -lgcc).

Could you help e understand why the definition of __mulsi3 is not used from
libgcc.a when I test "gcc test_program.c"?

Best regards
Navid


      





----------------------------------------------------------------------
Sprawdz, co wyswietlaja kina w Twoim miescie!
http://link.interia.pl/f2028


      





----------------------------------------------------------------------
Kochanka - kobieta drugiej kategorii?
sprawdz >>>http://link.interia.pl/f2026

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

* Re: modifying libgcc.a
  2009-01-22 20:21 ` Navid Toosizadeh
  2009-01-22 21:01   ` Blazej
@ 2009-01-23 15:59   ` Ian Lance Taylor
  1 sibling, 0 replies; 6+ messages in thread
From: Ian Lance Taylor @ 2009-01-23 15:59 UTC (permalink / raw)
  To: Navid Toosizadeh; +Cc: gcc-help

Navid Toosizadeh <navid_toosizadeh@yahoo.com> writes:

> When I do "gcc test.program.c -lgcc", it works. Does that mean
> linker does not link the output of gcc with libgcc? Should I seek
> for the problem in gcc or in my linker? (perior to changing libgcc,
> I never needed to use libgcc).

On many systems the default compilation links against -lgcc_s, not
-lgcc.  Use the -v option to see the arguments being passed to the
linker.

Ian

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

end of thread, other threads:[~2009-01-23 15:59 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-01-22 18:08 modifying libgcc.a Navid Toosizadeh
2009-01-22 20:21 ` Navid Toosizadeh
2009-01-22 21:01   ` Blazej
2009-01-22 21:13     ` Navid Toosizadeh
2009-01-22 21:26       ` Blazej
2009-01-23 15:59   ` Ian Lance Taylor

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