[Barrelfish-users] netd and howto get files into BF/Qemu

Simon Peter speter at inf.ethz.ch
Thu Dec 15 13:27:15 CET 2011


Perfect. I wonder if we could integrate this somehow with hake such that 
you just specify that you want vfs support and it will add the library 
and set the required linker option.

Simon

On 15.12.2011 11:56, Kornilios Kourtis wrote:
> Hi,
>
> On Wed, Dec 14, 2011 at 04:21:21PM +0000, Peter  Simon wrote:
>> I think Ihor ran into this problem before (with the same unclean fix).
>> vfs_init() sets up the linkage between libc and libvfs, but the linker
>> decides not to call it, as there's nothing explicitly calling libvfs
>> from libc.
>>
>> Does anyone know how to force the linker to call a constructor? That
>> would solve this problem.
>
> The problem probably is that libc does not reference any of the libvfs symbols,
> so the module is not linked at all. A trick to force ld to link libvfs is to
> explicitly set a vfs symbol as undefined  when linking. This can be done by
> passing --undefined=vfs_dummy (maybe this is why vfs_dummy was there?) to ld,
> or -Xlinker --undefined=vfs_dummy to gcc.
>
> I've tested a simple example:
> $ cat ../usr/tests/filetests/fopen_test.c
> #include<stdio.h>
> int main(int argc, char *argv[])
> {
>      FILE *fh = fopen("PIZZA", "w");
>      fclose(fh);
>      return 0;
> }
> $ tail -5 ../usr/tests/filetests/Hakefile
>    build application { target = "fopen_test",
>                        cFiles = [ "fopen_test.c" ],
>                        addLibraries = ["vfs", "nfs", "lwip", "contmng", "timer" ]
>                      }
>    ]
> $ make ./x86_64/sbin/fopen_test
> gcc [lots of options]
> $ nm ./x86_64/sbin/fopen_test | grep vfs | wc -l
> 0
> $ gcc -Xlinker --undefined=vfs_dummy  [lots of options]
> $ nm ./x86_64/sbin/fopen_test | grep vfs | wc -l
> 234
>
> cheers,
> Kornilios.
>




More information about the Barrelfish-users mailing list