diff options
author | mcgrathr@chromium.org <mcgrathr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-09-07 18:07:20 +0000 |
---|---|---|
committer | mcgrathr@chromium.org <mcgrathr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-09-07 18:07:20 +0000 |
commit | 1ed241636eecfc6d7b1b67511080fa49876cdae5 (patch) | |
tree | 4a481af19ab95acbbf3437c8c95108aee90920b3 /chrome/nacl | |
parent | 916cd9a54573ca70d0e60b775e56a5b4b8a8c404 (diff) | |
download | chromium_src-1ed241636eecfc6d7b1b67511080fa49876cdae5.zip chromium_src-1ed241636eecfc6d7b1b67511080fa49876cdae5.tar.gz chromium_src-1ed241636eecfc6d7b1b67511080fa49876cdae5.tar.bz2 |
nacl_helper_bootstrap: Avoid writable text segment
Using linux_syscall_support.h requires having a global variable
(for the local errno), which I did not have in my original version.
Hence, we now have bss space, where originally I had none at all.
This updates the linker script to have a proper data+bss segment.
Without this, the text segment winds up both writable and executable,
which is generally frowned upon (and requires extra special privileges
in some Linux systems).
BUG= none
TEST= hand-verified that the build comes out as intended and still works
R=bradchen@google.com
Review URL: http://codereview.chromium.org/7840012
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@99975 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/nacl')
-rw-r--r-- | chrome/nacl/nacl_helper_bootstrap_linux.x | 16 | ||||
-rwxr-xr-x | chrome/nacl/nacl_helper_bootstrap_munge_phdr.py | 2 |
2 files changed, 17 insertions, 1 deletions
diff --git a/chrome/nacl/nacl_helper_bootstrap_linux.x b/chrome/nacl/nacl_helper_bootstrap_linux.x index 5eae077..169bc0d 100644 --- a/chrome/nacl/nacl_helper_bootstrap_linux.x +++ b/chrome/nacl/nacl_helper_bootstrap_linux.x @@ -46,6 +46,7 @@ RESERVE_TOP = 1 << 30; */ PHDRS { text PT_LOAD FILEHDR PHDRS; + data PT_LOAD; reserve PT_LOAD FLAGS(0); stack PT_GNU_STACK FLAGS(6); /* RW, no E */ } @@ -66,6 +67,21 @@ SECTIONS { etext = .; /* + * Adjust the address for the data segment. We want to adjust up to + * the same address within the page on the next page up. + */ + . = (ALIGN(CONSTANT(MAXPAGESIZE)) - + ((CONSTANT(MAXPAGESIZE) - .) & (CONSTANT(MAXPAGESIZE) - 1))); + . = DATA_SEGMENT_ALIGN(CONSTANT(MAXPAGESIZE), CONSTANT(COMMONPAGESIZE)); + + .data : { + *(.data*) + } :data + .bss : { + *(.bss*) + } + + /* * Now we move up to the next p_align increment, and place the dummy * segment there. The linker emits this segment with the p_vaddr and * p_memsz we want, which reserves the address space. But the linker diff --git a/chrome/nacl/nacl_helper_bootstrap_munge_phdr.py b/chrome/nacl/nacl_helper_bootstrap_munge_phdr.py index c3a3931..7a53374 100755 --- a/chrome/nacl/nacl_helper_bootstrap_munge_phdr.py +++ b/chrome/nacl/nacl_helper_bootstrap_munge_phdr.py @@ -28,7 +28,7 @@ def Main(argv): [prog, munger, infile, outfile] = argv tmpfile = outfile + '.tmp' shutil.copy(infile, tmpfile) - segment_num = '1' + segment_num = '2' subprocess.check_call([munger, tmpfile, segment_num]) shutil.move(tmpfile, outfile) |