@@ -115,6 +115,22 @@ beos_dl_open(char *filename)
115115 }
116116}
117117
118+ void
119+ beos_dl_sym (image_id im ,char * symname ,void * * fptr )
120+ {
121+ /* Send command '3' (get symbol) to the support server */
122+ write_port (beos_dl_port_in , 3 , symname , strlen (symname ) + 1 );
123+ write_port (beos_dl_port_in , im , NULL ,0 );
124+
125+ /* Read sym address */
126+ read_port (beos_dl_port_out , (int32 * )(fptr ), NULL , 0 );
127+
128+ if (fptr == NULL )
129+ {
130+ elog (NOTICE , "loading symbol '%s' failed " , symname );
131+ }
132+ }
133+
118134status_t
119135beos_dl_close (image_id im )
120136{
@@ -164,12 +180,13 @@ beos_startup(int argc, char **argv)
164180 * server
165181 */
166182 read_port (port_in , & opcode , datas , 4000 );
167-
183+
168184 switch (opcode )
169185 {
170186 image_id addon ;
171187 image_info info_im ;
172188 area_info info_ar ;
189+ void * fpt ;
173190
174191 /* Load Add-On */
175192 case 1 :
@@ -208,6 +225,33 @@ beos_startup(int argc, char **argv)
208225 write_port (port_out , unload_add_on (* ((int * ) (datas ))), NULL , 0 );
209226 break ;
210227 /* Cleanup and exit */
228+ case 3 :
229+
230+ /* read image Id on the input port */
231+ read_port (port_in , & addon ,NULL ,0 );
232+
233+ /* Loading symbol */
234+ fpt = NULL ;
235+
236+
237+ if (get_image_symbol (addon , datas , B_SYMBOL_TYPE_TEXT , & fpt ) == B_OK );
238+ {
239+
240+ /*
241+ * Sometime the loader return B_OK for an inexistant function
242+ * with an invalid address !!! Check that the return address
243+ * is in the image range
244+ */
245+
246+ get_image_info (addon , & info_im );
247+ if ((fpt < info_im .text ) || (fpt >= (info_im .text + info_im .text_size )))
248+ fpt = NULL ;
249+ }
250+
251+ /* Send back fptr of data segment */
252+ write_port (port_out , (int32 )(fpt ),NULL ,0 );
253+ break ;
254+
211255 default :
212256 /* Free system resources */
213257 delete_port (port_in );
0 commit comments