Re: Aligning function on a page boundary

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Feb 27, 2008 at 02:59:41PM +0100, Igor Bukanov wrote:
> Hi Sam,
> 
> I have tried to use __attribute__((section("xxx")), but it seems there
> are no linker options to force a particular alignment for a section
> for ELF. All those nice alignment options refers to Windows:
> 
> --section-alignment
>            Sets  the  section alignment.  Sections in memory will
> always begin at addresses which are a multiple of this number.
> Defaults to 0x1000.  [This option is specific to the i386 PE targeted
> port of the linker]
> 
> I can only force the section to start on a particular address when
> loaded. Then it works. But this is not what as I have no idea what the
> address should be.
> 
> Have I missed something?

You need to provide your own linker script and then you can
adjust '.' to a page aligned address.

Sample from the kernel linker script:

 /* read-only */
  .text : AT(ADDR(.text) - LOAD_OFFSET) {
        . = ALIGN(4096);
        *(.text.page_aligned)



ld can generate the current default linekr script that you can base
your changes upon.

	Sam

[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux