Test Case Included:... __attribute__ ((aligned (16384)))==>Not enough room for program headers(allocated 7, need 8) - X

This is a discussion on Test Case Included:... __attribute__ ((aligned (16384)))==>Not enough room for program headers(allocated 7, need 8) - X ; Hello, On Linux, if I use the "-N" option with the below test case it compiles (g++) and runs perfectly, but I get "undefined" when I try to compile an X application with the aligned attribute, using g++. Without the ...

+ Reply to Thread
Results 1 to 6 of 6

Thread: Test Case Included:... __attribute__ ((aligned (16384)))==>Not enough room for program headers(allocated 7, need 8)

  1. Test Case Included:... __attribute__ ((aligned (16384)))==>Not enough room for program headers(allocated 7, need 8)

    Hello,

    On Linux, if I use the "-N" option with the below test case it
    compiles (g++) and runs perfectly, but I get "undefined" when I try to
    compile an X application with the aligned attribute, using g++.

    Without the "-N" option the linker complains with the message on the
    subject line.

    /************************* Program 1: test.c ***********************/
    struct
    {
    int t1;
    int t2;
    int tx;
    } shared_memory __attribute__ ((aligned (16384)));

    int main ()
    {
    printf ("address is %X\n",&shared_memory);
    }
    /************************* But Program 2 Woun't Compile ***********/

    When I compile it, I get:
    undefined reference to XmStringCreateLtoR
    undefined reference to XtVASetValues
    ....

    These undefineds are in standard X libraries.

    Note: Without the described attribute, the program compiles. But it's
    incorrect because of the variable's address isn't want I want!

    If I surround the library includes with extern "C" the compiler
    complains about the line with the extern. I mention this because that
    is the standard way of linking C++ files to C files.

    What can I do to get the X application to compile and run with the
    shared_memory aligned to some 16384 address?

    Thank you,
    Christopher Lusardi

  2. Re: Test Case Included:... __attribute__ ((aligned (16384)))==>Not enough room for program headers(allocated 7, need 8)

    clusardi2k@aol.com (Christopher M. Lusardi) writes:
    >Hello,
    >
    > On Linux, if I use the "-N" option with the below test case it
    >compiles (g++) and runs perfectly, but I get "undefined" when I try to
    >compile an X application with the aligned attribute, using g++.
    >
    > Without the "-N" option the linker complains with the message on the
    >subject line.
    >
    >/************************* Program 1: test.c ***********************/
    >struct
    >{
    > int t1;
    > int t2;
    > int tx;
    >} shared_memory __attribute__ ((aligned (16384)));


    You can fix this by changing this line to:

    } shared_memory __attribute__ ((aligned (16384))) = {};

    which will cause the compiler to emit code to properly align
    a storage area allocated in the .data segment. If you
    don't initialize it, the compiler will emit a .comm op for
    the area which the linker apparently doesn't like (a probable bug, IMHO).

    (look at the source file using "cc -S test.c" and examine test.s with your
    favorite editor).

    scott



  3. Re: Test Case Included:... __attribute__ ((aligned (16384)))==>Notenough room for program headers(allocated 7, need 8)

    Christopher M. Lusardi wrote:
    >
    > What can I do to get the X application to compile and run with the
    > shared_memory aligned to some 16384 address?


    It may not be possible. The docs for GCC indicate that the alignment
    limits are dependent upon the limits of ld for the platform. 16384
    bytes is a larger than usual alignment value and may not be possible on
    all platforms.

  4. Re: Test Case Included:... __attribute__ ((aligned (16384)))==>Not enough room for program headers(allocated 7, need 8)

    scott@slp53.sl.home (Scott Lurndal) wrote in message news:...
    > clusardi2k@aol.com (Christopher M. Lusardi) writes:
    > >struct
    > >{
    > > int t1;
    > > int t2;
    > > int tx;
    > >} shared_memory __attribute__ ((aligned (16384)));

    >
    > You can fix this by changing this line to:
    >
    > } shared_memory __attribute__ ((aligned (16384))) = {};
    >
    > which will cause the compiler to emit code to properly align
    > a storage area allocated in the .data segment. If you
    > don't initialize it, the compiler will emit a .comm op for
    > the area which the linker apparently doesn't like (a probable bug, IMHO).
    >


    That fixed the problem for me. Thanks to you and everyone else who
    answered my posting.

    Chris Lusardi

  5. Re: Test Case Included:... __attribute__ ((aligned (16384)))==>Not enough room for program headers(allocated 7, need 8)

    clusardi2k@aol.com (Christopher M. Lusardi) wrote:

    >Hello,
    >
    > On Linux, if I use the "-N" option with the below test case it
    >compiles (g++) and runs perfectly, but I get "undefined" when I try to
    >compile an X application with the aligned attribute, using g++.
    >
    > Without the "-N" option the linker complains with the message on the
    >subject line.
    >
    >/************************* Program 1: test.c ***********************/
    >struct
    >{
    > int t1;
    > int t2;
    > int tx;
    >} shared_memory __attribute__ ((aligned (16384)));


    What's the point of any alignment less granular than a page (4096)? And
    does the ELF format guarantee that sections will be aligned at anything
    greater than 4k? Having a variable aligned to 16k within the section
    doesn't do any good if the section is aligned to 4k.
    --
    - Tim Roberts, timr@probo.com
    Providenza & Boekelheide, Inc.

  6. Re: Test Case Included:... __attribute__ ((aligned (16384)))==>Not enough room for program headers(allocated 7, need 8)

    Tim Roberts wrote:
    >clusardi2k@aol.com (Christopher M. Lusardi) wrote:
    >
    >>Hello,
    >>
    >> On Linux, if I use the "-N" option with the below test case it
    >>compiles (g++) and runs perfectly, but I get "undefined" when I try to
    >>compile an X application with the aligned attribute, using g++.
    >>
    >> Without the "-N" option the linker complains with the message on the
    >>subject line.
    >>
    >>/************************* Program 1: test.c ***********************/
    >>struct
    >>{
    >> int t1;
    >> int t2;
    >> int tx;
    >>} shared_memory __attribute__ ((aligned (16384)));

    >
    >What's the point of any alignment less granular than a page (4096)? And
    >does the ELF format guarantee that sections will be aligned at anything
    >greater than 4k? Having a variable aligned to 16k within the section


    The ELF format can handle alignment to arbitrary powers of two on a
    section.

    There are situations in which it makes sense to align a virtual
    address to something greater than a page boundary, eg to allow
    relative addressing or tag bits.

    And, it makes sense for the tool chain to support sizes greater than a
    page because, for example, you see 8192-byte pages on RISC machines,
    or, some operating systems have used a logical pagesize greater than
    the physical pagesize.

    Despite all of this, the above attribute/aligned method is simply bad
    programming and should never be used.


+ Reply to Thread