From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 61098 invoked by alias); 18 Nov 2015 15:59:56 -0000 Mailing-List: contact ecos-discuss-help@ecos.sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: ecos-discuss-owner@ecos.sourceware.org Received: (qmail 61087 invoked by uid 89); 18 Nov 2015 15:59:55 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.7 required=5.0 tests=AWL,BAYES_00,FREEMAIL_FROM,MALFORMED_FREEMAIL,RCVD_IN_DNSWL_LOW,SPF_PASS autolearn=no version=3.3.2 X-HELO: mail-wm0-f41.google.com Received: from mail-wm0-f41.google.com (HELO mail-wm0-f41.google.com) (74.125.82.41) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Wed, 18 Nov 2015 15:59:54 +0000 Received: by wmec201 with SMTP id c201so285756052wme.0 for ; Wed, 18 Nov 2015 07:59:51 -0800 (PST) X-Received: by 10.28.21.9 with SMTP id 9mr5126898wmv.22.1447862391035; Wed, 18 Nov 2015 07:59:51 -0800 (PST) Received: from sg-laptop ([178.121.161.199]) by smtp.gmail.com with ESMTPSA id da10sm3497906wjb.22.2015.11.18.07.59.50 (version=TLS1 cipher=AES128-SHA bits=128/128); Wed, 18 Nov 2015 07:59:50 -0800 (PST) Date: Wed, 18 Nov 2015 15:59:00 -0000 From: Sergei Gavrikov To: Robert H cc: ecos-discuss@ecos.sourceware.org In-Reply-To: Message-ID: References: User-Agent: Alpine 2.00 (DEB 1167 2008-08-23) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-IsSubscribed: yes Subject: Re: [ECOS] Re: ecos hal symbol table creation mechanism X-SW-Source: 2015-11/txt/msg00006.txt.bz2 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