[9fans] a question on style - Plan9

This is a discussion on [9fans] a question on style - Plan9 ; For some time now, over 10 years anyway, the GNU world has been using the linker to create initialized structs, viz: static const struct cpu_driver driver __cpu_driver = { .ops = &cpu_dev_ops, .id_table = cpu_table, }; (this from linuxbios) The ...

+ Reply to Thread
Results 1 to 6 of 6

Thread: [9fans] a question on style

  1. [9fans] a question on style

    For some time now, over 10 years anyway, the GNU world has been using
    the linker to create initialized structs, viz:
    static const struct cpu_driver driver __cpu_driver = {
    .ops = &cpu_dev_ops,
    .id_table = cpu_table,
    };

    (this from linuxbios)

    The __cpu_driver is passed to the linker and you end up with an array
    of all structs tagged with that name.

    These are called linker sets. I first heard of them in 1995 or so when
    freebsd moved away from generating arrays of structs from the BSD
    config tool and used gld to create those same arrays.

    Plan 9 takes the older style approach: a script parses a config file
    and creates C code which initializes the struct arrays.

    Now, I betray my age, I guess, but I prefer the plan 9 style. I am
    curious: am I just out of touch with this modern world?

    Why do I like the Plan 9 style?
    1. you can figure out what source constitutes the
    program/application/os/bios by looking at C code
    2. program analysis tools can analyse C code; you don't need binaries
    and linker scripts
    3. Errors such as empty structs are easier to catch at build time;
    we've seen cases where nobody
    built a binary with, e.g., any cpu drivers and we did not know
    until the BIOS tried to start
    4. If you are using, e.g., Eclipse or Kscope, you can see how code is
    invoked and used, which is
    harder when initialized structs are created by the linker.

    OK, am I just out of date or is there a real reason for linker
    sets?This question just came up in linuxbios v3 and I am wondering if
    I am a stubborn old coot (likely) or if there really is merit to my
    dislike of linker sets.

    ron


  2. Re: [9fans] a question on style

    > OK, am I just out of date or is there a real reason for linker
    > sets?This question just came up in linuxbios v3 and I am wondering if
    > I am a stubborn old coot (likely) or if there really is merit to my
    > dislike of linker sets.


    why can't both be true?

    - erik



  3. Re: [9fans] a question on style

    On Thu, Jul 31, 2008 at 3:04 PM, erik quanstrom wrote:
    >> OK, am I just out of date or is there a real reason for linker
    >> sets?This question just came up in linuxbios v3 and I am wondering if
    >> I am a stubborn old coot (likely) or if there really is merit to my
    >> dislike of linker sets.

    >
    > why can't both be true?
    >


    I suspect both are true ...

    ron


  4. Re: [9fans] a question on style

    On Thu, 2008-07-31 at 15:02 -0700, ron minnich wrote:
    > OK, am I just out of date or is there a real reason for linker
    > sets?This question just came up in linuxbios v3 and I am wondering if
    > I am a stubborn old coot (likely) or if there really is merit to my
    > dislike of linker sets.


    I tend to dislike any kind of linker magic in user-space quite
    profoundly. The most I can tolerate is PLT, I guess. But even
    that is something I don't appreciate all that much when I need
    to debug low level code. So I agree with you there 100%.

    Now, on the other hand, I guess kernel is different though.
    Isn't it supposed to be one huge piece of magic to begin with? ;-)

    Thanks,
    Roman.



  5. Re: [9fans] a question on style

    > Now, on the other hand, I guess kernel is different though.
    > Isn't it supposed to be one huge piece of magic to begin with? ;-)


    it's supposed to be neither.

    - erik



  6. Re: [9fans] a question on style

    On Fri, 2008-08-01 at 06:06 -0400, erik quanstrom wrote:
    > > Now, on the other hand, I guess kernel is different though.
    > > Isn't it supposed to be one huge piece of magic to begin with? ;-)

    >
    > it's supposed to be neither.


    Yeah, but Ron was talking 'bout that kernel from Scandinavia,
    right?

    Thanks,
    Roman.



+ Reply to Thread