1

Could anyone please point me out what is the limitation to the alignment value which makes the creation of multiple segment for a section.

With The test case mentioned below:

#include <stdio.h>
#define SIZE (1 << 11)

int Buffer[SIZE]  __attribute__ ((aligned (SIZE * sizeof(int)))) ;

int main (int argc, char * argv[])
{
printf("Test\n");
return 0;
}

And here if i change the macro as:

#define SIZE (1 << 11) to #define SIZE (1 << 12)

Without the above changes we see only two loadable segment while with the above changes we observed three loadable segment. As the alignment of BSS changes from 8K to 16K for GCC 4.8.1 which creates three loadable segments.

So can anyone please tell me what changes need to be done in linker script to make creation of only one loadable segment for data.

1
  • This i have observed for i686 machine. Commented May 19, 2016 at 9:55

2 Answers 2

1

There are two ways of creating a linker script: 1. Under ld/emulparam directory there are shell script which creates linker script. 2. While other part of linker script came from the actual source.

Now in the source part there depends which linker you are using ie. GNU linker or gold linker.

Sign up to request clarification or add additional context in comments.

Comments

1

GNU Linker script is build based on:

  1. Under directory ~/binutils-2013.11/ld/emulparams/, there are different architecture specifics shell script based on different ELF type and platform like for i386/Vxworks

elf_i386_vxworks.sh

  1. While still the rest of generic contains in the script came from the ld/elf sources.

While about segment creation then please look into procedure **bfd_boolean _bfd_elf_map_sections_to_segments (bfd *abfd, struct bfd_link_info *info)** under source "bfd/elf.c"

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.