Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

For ARM, same symbols in library meant for different archs?

6 views
Skip to first unread message

me

unread,
May 28, 2011, 5:06:06 PM5/28/11
to
Hi guys,

I just posted this in gnu.gcc.help a while ago, but google reveals
this is where I should have posted on a first instace!

Basically, I compiled a chain for arm-elf last week (bleeding edge
versions of all), been writing some code for it, and I'm now wondering
if the following could be possible:

Say I want function `foo' to be accessible at link-time for both,
armv6 and armv7, being both in the same library.

For this I would write two different functions which I guess would get
in depending on what is being defined due to the `-mcpu' command-line
option, either `__ARM_ARCH_6M__' or `__ARM_ARCH_7M__' in this case.

Skiming through the docs, it seems I could use the attribute `ifunc
("resolver")', or also the `target' attribute.

But I guess both of them require specific support for each target
arch, which seems not to be the case for ARM's as I get something
along the lines of "this is not supported on this machine".

Is there anyway this can be done in a "proffesional" way, yet having
same name for both versions of the functions?

Thanks,

Eduardo.

Hans-Bernhard Bröker

unread,
May 29, 2011, 10:49:49 AM5/29/11
to
On 28.05.2011 23:06, me wrote:

> I just posted this in gnu.gcc.help a while ago, but google reveals
> this is where I should have posted on a first instace!

Not really.

> Say I want function `foo' to be accessible at link-time for both,
> armv6 and armv7, being both in the same library.

Why the insistence on a single library? What do you want that for?

GCC has a dedicated facility for this kind of work, called 'multilib'.
It basically means you have _separate_ libs for different (sub)targets,
installed in different directories, and GCC will automatically pick one
of those libs based on the selected target.

> For this I would write two different functions which I guess would get
> in depending on what is being defined due to the `-mcpu' command-line
> option, either `__ARM_ARCH_6M__' or `__ARM_ARCH_7M__' in this case.

No. Macros don't (directly) influence library selection, nor selection
of functions from libraries.

me

unread,
May 29, 2011, 2:24:18 PM5/29/11
to
On May 29, 3:49 pm, Hans-Bernhard Bröker <HBBroe...@t-online.de>
wrote:

Hi Hans,

Thanks, I'll look into the multilib thing, didn't even know it existed
you see.

What I'm after is of a cmsis library I can use for cortex-m3 and
cortex-m0 (or even cortex-m4 in a future) as the only difference among
them would be (structures, which grow with version number, and code
for each function). Besides of this, the api is almost the same.

How do you guys go arround this?

What I thougth first was to have a library for each subtarget, perhaps
even sharing a common header file (ifdef'ed as needed). It's just that
I happened to think if a cleaner solution would be available at this
time.

Regards,

Roberto Waltman

unread,
May 29, 2011, 6:29:53 PM5/29/11
to
me wrote:
>> > Say I want function `foo' to be accessible at link-time for both,
>> > armv6 and armv7, being both in the same library.
>
>How do you guys go arround this?

As a previous poster wrote. Why?
I would not attempt it at all. Keeping separate libraries for
different ARM cores is the simplest method.
Remember the KISS principle?
--
Roberto Waltman

[ Please reply to the group,
return address is invalid ]

0 new messages