From: Sergei Gavrikov <sergei.gavrikov@gmail.com>
To: Robert H <robert.huem@gmail.com>
Cc: ecos-discuss@ecos.sourceware.org
Subject: Re: [ECOS] Re: ecos hal symbol table creation mechanism
Date: Wed, 18 Nov 2015 15:59:00 -0000 [thread overview]
Message-ID: <alpine.DEB.2.00.1511181742540.2511@sg-laptop> (raw)
In-Reply-To: <CAJMZFXfLoHo7N_iNckj_Mxzoo0z4ER1BP8uNZvECov84LuuKcQ@mail.gmail.com>
On Wed, 18 Nov 2015, Robert H wrote:
> 2015-11-17 Sergei Gavrikov wrote:
> > On Mon, 16 Nov 2015, Robert H wrote:
[snip]
> >> I would be very pleased to know more about how the mechanism to get
> >> ecos symbols works in hal_tables.h
> >
> > Generally and particularly (objloader case) the table boundaries are
> > known
> >
> > https://sourceware.org/viewvc/ecos/packages/services/objloader/current/src/objelf.c?view=markup#l62
> >
> > Look up example, objelf.c:cyg_ldr_external_address():
> >
> > https://sourceware.org/viewvc/ecos/packages/services/objloader/current/src/objelf.c?view=markup#l219
> I probably still don't get it by looking at the source code how
> entry->handler gets filled with the address of the symbol_name in the
> ecos image.
>
> cyg_ldr_external_address is for accessing the symbol table in that
> section until the entry-pointer reached the cyg_ldr_table_end-pointer,
> but to me that still doesn't explain how entry->handler gets filled by
> the right address.
Notice, that eCos table macros is a quite smart way to declare the
arrays of some C structure and keep them in a special memory region.
For your case the array's item (or "row" of the table) is C struct
cyg_ldr_table_entry:
https://sourceware.org/viewvc/ecos/packages/services/objloader/current/include/objelf.h?revision=1.7&view=markup#l133
Similar in plain C
extern int bar();
extern int foo();
struct s {
char *name;
void *call;
};
struct s table[] = { { "bar", bar }, {"foo", foo}, };
struct s *table_end = &table[sizeof table / sizeof table[0]];
struct s *entry = table;
while(entry != table_end) {
if(strcmp(entry->name, "foo") == 0) {
return entry->call;
}
entry++;
}
Hope, that no magic anymore.
Sergei
--
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss
prev parent reply other threads:[~2015-11-18 15:59 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-11-18 7:43 Robert H
2015-11-18 15:59 ` Sergei Gavrikov [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=alpine.DEB.2.00.1511181742540.2511@sg-laptop \
--to=sergei.gavrikov@gmail.com \
--cc=ecos-discuss@ecos.sourceware.org \
--cc=robert.huem@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).