Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2001-06

Dynamic Symbol Information For Functions and Procedures in Linux ELF

9 messages · 3 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Ecmel ERCAN

Hi,

I am new to Linux and Free Pascal so please forgive me If I am asking a silly question :)

I have converted libglade headers to free pascal but I need to know how to include the dynamic symbol information for gtk event handler functions in the final ELF file.

For example; I compile the following C program:

#include <gtk/gtk.h>
#include <glade/glade.h>

void on_window1_destroy(GtkWidget *widget, gpointer user_data) { /* do something useful here */

  gtk_main_quit();

}

int main(int argc, char *argv[]) {
    GladeXML *xml;
    gtk_init(&argc, &argv);
    glade_gnome_init();
    /* load the interface */
    xml = glade_xml_new("test.glade", NULL);
    /* connect the signals in the interface */
    glade_xml_signal_autoconnect(xml);
    /* start the event loop */
    gtk_main();
    return 0;
}

Now if I use objdump -T on the generated ELF file, I can see the on_window1_destroy function is in the list.

But when I compile the pascal version it does not get into the dynamic symbol info table:

program test;
uses glib, gdk, gtk, glade;
var
   TestXML	 : PGladeXML;
procedure on_window1_destroy (widget : PGtkWidget; data: Pgpointer); cdecl;
begin
   gtk_main_quit();
end;
begin
   gtk_init(@argc, @argv);
   glade_init;
   TestXML := glade_xml_new('test.glade', nil);
   glade_xml_signal_autoconnect(TestXML);
   gtk_main();
end.

Because of this, glade_xml_signal_autoconnect function does not work properly in the pascal version.

Please help :)

Thanks in advance for the replies.

Ecmel Ercan

PS: I can manually attach the event handlers and Glade works great with FPC. If only I can auto-magically connect the event handlers, everything will be much more easy and clean.

Michael Van Canneyt
to Ecmel ERCAN
Ecmel ERCAN wrote 41 lines
Hi, I am new to Linux and Free Pascal so please forgive me If I am asking a silly question :) I have converted libglade headers to free pascal but I need to know how to include the dynamic symbol information for gtk event handler functions in the final ELF file. For example; I compile the following C program: #include <gtk/gtk.h> #include <glade/glade.h> void on_window1_destroy(GtkWidget *widget, gpointer user_data) { /* do something useful here */ gtk_main_quit(); } int main(int argc, char *argv[]) { GladeXML *xml; gtk_init(&argc, &argv); glade_gnome_init(); /* load the interface */ xml = glade_xml_new("test.glade", NULL); /* connect the signals in the interface */ glade_xml_signal_autoconnect(xml); /* start the event loop */ gtk_main(); return 0; } Now if I use objdump -T on the generated ELF file, I can see the on_window1_destroy function is in the list. But when I compile the pascal version it does not get into the dynamic symbol info table:

The problem is that 'on_window1_destroy' is mangled to ON_WINDOW1_DESTROY$$XX$YY etc. This is necessary because
1) Pascal is case sensitive
2) We support overloading of funtions.
So names are mangled. One way to solve this is to put an alias modifier behind it:

procedure on_window1_destroy (widget : PGtkWidget; data: Pgpointer); cdecl; [alias: 'on_window1_destroy'];

This will create an extra symbol with the correct casing.

Michael.

Ecmel ERCAN
to Michael Van Canneyt

Hi,

Thanks for the answer, but I have tried this before and no way successful.

When I type:

objdump -T test

The on_window1_destroy is not listed there.

Ecmel

------------
The output of objdump -T on the generated elf:

test: file format elf32-i386

DYNAMIC SYMBOL TABLE:
08049cd0 DF *UND* 00000041
gtk_tearoff_menu_item_get_type
08049ce0 DF *UND* 00000041 gtk_menu_get_type 08049cf0 DF *UND* 00000041
gtk_toggle_button_get_type
08049d00 DF *UND* 0000038d
g_datalist_id_set_data_full
08049d10 DF *UND* 00000041
gtk_color_selection_get_type
08049d20 DF *UND* 00000041
gtk_radio_button_get_type
08049d30 DF *UND* 00000041 gtk_curve_get_type 0805c610 g DO .bss 00000004 gdk_root_window 08049d40 DF *UND* 00000041 gtk_vscale_get_type 08049d50 DF *UND* 00000041
gtk_hbutton_box_get_type
08049d60 DF *UND* 00000041 gtk_ruler_get_type 08049d70 DF *UND* 00000041
gtk_scrolled_window_get_type
08049d80 DF *UND* 00000041 gtk_text_get_type 08049d90 DF *UND* 00000041 gtk_vpaned_get_type 0805c51c g DO *ABS* 00000000 Base _DYNAMIC 08049da0 DF *UND* 00000155
g_datalist_id_remove_no_notify
08049db0 DF *UND* 000000cb gtk_type_is_a 08049dc0 w DF *UND* 00000081 GLIBC_2.0 __register_frame_info 08049dd0 DF *UND* 00000041 gtk_statusbar_get_type 08049de0 DF *UND* 00000041 gtk_calendar_get_type 08049df0 DF *UND* 00000041 gtk_preview_get_type 08049e00 DF *UND* 00000041 gtk_tree_item_get_type 08049e10 DF *UND* 00000041 gtk_hbox_get_type 08049e20 DF *UND* 0000009d g_strchug 08049e30 DF *UND* 00000041 gtk_invisible_get_type 08049e40 DF *UND* 00000041 gtk_hruler_get_type 08049e50 DF *UND* 00000104 g_quark_try_string 08049e60 DF *UND* 00000041 gtk_vbox_get_type 08049e70 DF *UND* 00000041 gtk_fixed_get_type 08049e80 DF *UND* 00000041 gtk_event_box_get_type 08049e90 DF *UND* 00000041 gtk_progress_get_type 08049ea0 DF *UND* 00000041
gtk_radio_menu_item_get_type
08049eb0 DF *UND* 00000041
gtk_gamma_curve_get_type
08049ec0 DF *UND* 00000041 gtk_item_get_type 08049ed0 DF *UND* 00000041
gtk_check_button_get_type
08049ee0 DF *UND* 00000041 gtk_table_get_type 0805c614 g DO .bss 00000004 gdk_display 08049ef0 DF *UND* 00000041 gtk_misc_get_type 08049f00 DF *UND* 00000041
gtk_font_selection_get_type
08049f10 DF *UND* 00000041 gtk_list_get_type 08049f20 DF *UND* 00000102 g_node_insert 08049cac g DF .init 00000000 Base _init 08049f30 DF *UND* 00000056 gtk_menu_item_get_type 08049f40 DF *UND* 00000041 gtk_hscrollbar_get_type 08049f50 DF *UND* 00000041 gtk_box_get_type 08049f60 DF *UND* 00000041 gtk_window_get_type 08049f70 DF *UND* 00000041 gtk_scale_get_type 08049f80 DF *UND* 00000138 g_node_insert_before 08049f90 w DF *UND* 000000ac GLIBC_2.0 __deregister_frame_info 08049fa0 DF *UND* 00000041 gtk_handle_box_get_type 08049fb0 DF *UND* 00000041 gtk_menu_shell_get_type 08049fc0 DF *UND* 00000041 gtk_scrollbar_get_type 08049fd0 DF *UND* 00000041 gtk_dialog_get_type 08049fe0 DF *UND* 00000056 gtk_label_get_type 08049ff0 DF *UND* 0000007b g_array_insert_vals 0804a000 DF *UND* 00000041 gtk_frame_get_type 0804a010 DF *UND* 00000041 gtk_vscrollbar_get_type 0804a020 DF *UND* 00000137 g_quark_from_string 0804a030 DF *UND* 0000003a
gtk_item_factory_get_type
0804a040 DF *UND* 00000041
gtk_check_menu_item_get_type
0804a050 DF *UND* 00000041 gtk_combo_get_type 0804a060 DF *UND* 00000041 gtk_hscale_get_type 0804a070 DF *UND* 00000076 glade_xml_new 0804a080 DF *UND* 00000118 g_node_new 0804a090 DF *UND* 00000041
gtk_drawing_area_get_type
0804a0a0 DF *UND* 00000041
gtk_vbutton_box_get_type
0804a0b0 DF *UND* 00000055 gtk_init 0804a0c0 DF *UND* 00000041 gtk_arrow_get_type 0804a0d0 DF *UND* 00000061 g_array_prepend_vals 0804a0e0 DF *UND* 00000041
gtk_accel_label_get_type
0804a0f0 DF *UND* 00000041 gtk_image_get_type 0804a100 DF *UND* 0000005f gtk_main_quit 0804a110 DF *UND* 00000041
gtk_progress_bar_get_type
0804a120 DF *UND* 00000041 gtk_button_box_get_type 0804a130 DF *UND* 00000041 gtk_entry_get_type 0804a140 DF *UND* 00000041 gtk_editable_get_type 0804a150 DF *UND* 000001d4 gtk_main 0805c604 g DO *ABS* 00000000 Base __bss_start 0804a160 DF *UND* 00000183 g_dataset_id_get_data 0805c618 g DO .bss 00000034 gdk_root_parent 0804a170 DF *UND* 000000ca GLIBC_2.0 __libc_start_main 0804a180 DF *UND* 00000041 gtk_viewport_get_type 0804a190 DF *UND* 00000041 gtk_vseparator_get_type 0804a1a0 DF *UND* 00000041 gtk_clist_get_type 0804a1b0 DF *UND* 00000041 gtk_range_get_type 0804a1c0 DF *UND* 00000076 g_datalist_id_get_data 0804a1d0 DF *UND* 0000041d
g_dataset_id_set_data_full
0805af38 g DF .fini 00000000 Base _fini 0804a1e0 DF *UND* 00000041 gtk_menu_bar_get_type 0804a1f0 DF *UND* 0000004d g_array_append_vals 0804a200 DF *UND* 00000041 gtk_notebook_get_type 0804a210 DF *UND* 00000041 gtk_hseparator_get_type 0804a220 DF *UND* 0000009e g_strchomp 0804a230 DF *UND* 00000041
gtk_spin_button_get_type
0804a240 w DF *UND* 0000009d GLIBC_2.1.3 __cxa_finalize 0804a250 DF *UND* 00000041 gtk_pixmap_get_type 0804a260 DF *UND* 00000056 gtk_button_get_type 0804a270 DF *UND* 00000041 gtk_tooltips_get_type 0804a280 DF *UND* 00000039 gdk_xid_table_lookup 0804a290 DF *UND* 0000002f glade_init 0804a2a0 DF *UND* 00000066 g_node_prepend 0805c604 g DO *ABS* 00000000 Base _edata 0804a2b0 DF *UND* 00000041 gtk_paned_get_type 0805c334 g DO *ABS* 00000000 Base _GLOBAL_OFFSET_TABLE_ 0809d040 g DO *ABS* 00000000 Base _end
0804a2c0 DF *UND* 00000041
gtk_aspect_frame_get_type
0804a2d0 DF *UND* 00000041 gtk_list_item_get_type 0804a2e0 DF *UND* 00000041
gtk_file_selection_get_type
0804a2f0 DF *UND* 00000041 gtk_packer_get_type 0804a300 DF *UND* 00000041 gtk_adjustment_get_type 0804a310 DF *UND* 0000013a g_hook_insert_before 0804a320 DF *UND* 00000041
gtk_option_menu_get_type
0804a330 DF *UND* 00000041 gtk_tips_query_get_type 0804a340 DF *UND* 0000008e
glade_xml_signal_autoconnect
0804a350 DF *UND* 00000041 gtk_alignment_get_type 0804a360 DF *UND* 00000041 gtk_layout_get_type 0804a370 DF *UND* 0000006b gtk_identifier_get_type 0804a380 DF *UND* 00000041 gtk_data_get_type 0804a390 DF *UND* 00000041 gtk_container_get_type 0804a3a0 DF *UND* 00000056
gtk_font_selection_dialog_get_type
0804a3b0 DF *UND* 00000041 gtk_separator_get_type 0804a3c0 DF *UND* 00000041 gtk_bin_get_type 0804a3d0 DF *UND* 00000041 gtk_ctree_get_type 0804a3e0 DF *UND* 00000041 gtk_widget_get_type 0804a3f0 DF *UND* 00000041
gtk_input_dialog_get_type
0804a400 DF *UND* 00000041 gtk_hpaned_get_type 0804a410 DF *UND* 00000041 gtk_vruler_get_type 0804a420 DF *UND* 000001ad
g_dataset_id_remove_no_notify
00000000 w D *UND* 00000000 __gmon_start__

Michael Van Canneyt
to Ecmel ERCAN
Ecmel ERCAN wrote 9 lines
Hi, Thanks for the answer, but I have tried this before and no way successful. When I type: objdump -T test The on_window1_destroy is not listed there.

Are you stripping your binary ? The symbol will be removed then, since it is not used.

Michael.

Ecmel ERCAN
to Michael Van Canneyt

Hi,

I think there is a distinction between static symbols and dynamic symbols.

libglade auto-connect feature (which uses gmodule) works only with dynamic symbols and
the C program always generates dynamic symbols for on_window1_destroy function. Even after I strip the C binary, the dynamic symbols stay there.

On the other hand, FPC does not include any function -even those are actually used and called in the code, in the dynamic symbol table.

If I enable debug info, the function names are included in the static table but not in the dynamic one.

Is there a compiler directive/switch in FPC which does this?

Thank you

Ecmel

Michael Van Canneyt wrote 27 lines
On Fri, 1 Jun 2001, Ecmel ERCAN wrote: > Hi, > > Thanks for the answer, but I have tried this before and no way successful. > > When I type: > > objdump -T test > > The on_window1_destroy is not listed there. Are you stripping your binary ? The symbol will be removed then, since it is not used. Michael. _______________________________________________ fpc-pascal maillist - http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Michael Van Canneyt
to Ecmel ERCAN
Ecmel ERCAN wrote 16 lines
Hi, I think there is a distinction between static symbols and dynamic symbols. libglade auto-connect feature (which uses gmodule) works only with dynamic symbols and the C program always generates dynamic symbols for on_window1_destroy function. Even after I strip the C binary, the dynamic symbols stay there. On the other hand, FPC does not include any function -even those are actually used and called in the code, in the dynamic symbol table. If I enable debug info, the function names are included in the static table but not in the dynamic one. Is there a compiler directive/switch in FPC which does this?

Shortly said: No.

Michael.

Peter Vreman
to Ecmel ERCAN: I think there is a distinction between static symbols and dynamic symbols. libglade…
you wrote 16 lines
Hi, I think there is a distinction between static symbols and dynamic symbols. libglade auto-connect feature (which uses gmodule) works only with dynamic symbols and the C program always generates dynamic symbols for on_window1_destroy function. Even after I strip the C binary, the dynamic symbols stay there. On the other hand, FPC does not include any function -even those are actually used and called in the code, in the dynamic symbol table. If I enable debug info, the function names are included in the static table but not in the dynamic one. Is there a compiler directive/switch in FPC which does this?

If you can supply what we've to add the the assembler to generate dynamic symbols we can maybe at them in the compiler.

Peter

Ecmel ERCAN
to Peter Vreman

Hi,

Assembler is out of my leauge so I cannot help about it.

On the other hand I was experimenting with creating (.so) libs with FPC and I realized that if I export a function in a library it is actually included in the dynamic symbol table.

I mean in case of a shared dynamic library FPC actually does this.

Also, if anybody is interested in libglade headers and sample source code, I can post them.

Thank you all.

Ecmel

Peter Vreman wrote 34 lines
At 16:49 1-6-01, you wrote: >Hi, > >I think there is a distinction between static symbols and dynamic symbols. > >libglade auto-connect feature (which uses gmodule) works only with dynamic >symbols and >the C program always generates dynamic symbols for on_window1_destroy >function. Even after I strip the C binary, the dynamic symbols stay there. > >On the other hand, FPC does not include any function -even those are >actually used and called in the code, in the dynamic symbol table. > >If I enable debug info, the function names are included in the static >table but not in the dynamic one. > >Is there a compiler directive/switch in FPC which does this? If you can supply what we've to add the the assembler to generate dynamic symbols we can maybe at them in the compiler. Peter _______________________________________________ fpc-pascal maillist - http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Peter Vreman
to Ecmel ERCAN
you wrote
Hi, Assembler is out of my leauge so I cannot help about it.

Try gcc -S to let gcc output an assembler file. It's about the directives used in the assembler file, not the assembler instructions.

Show quoted text 6 lines
On the other hand I was experimenting with creating (.so) libs with FPC and I realized that if I export a function in a library it is actually included in the dynamic symbol table. I mean in case of a shared dynamic library FPC actually does this.

.so files are still not 100% ok as the compiler doesn't generate Position Independent Code (PIC).

Also, if anybody is interested in libglade headers and sample source code, I can post them.

You can add them to the contributed units page.

Peter