|
Packit Service |
19f098 |
/* dlopen test for PIE objects.
|
|
Packit Service |
19f098 |
Copyright (C) 2019 Free Software Foundation, Inc.
|
|
Packit Service |
19f098 |
This file is part of the GNU C Library.
|
|
Packit Service |
19f098 |
|
|
Packit Service |
19f098 |
The GNU C Library is free software; you can redistribute it and/or
|
|
Packit Service |
19f098 |
modify it under the terms of the GNU Lesser General Public
|
|
Packit Service |
19f098 |
License as published by the Free Software Foundation; either
|
|
Packit Service |
19f098 |
version 2.1 of the License, or (at your option) any later version.
|
|
Packit Service |
19f098 |
|
|
Packit Service |
19f098 |
The GNU C Library is distributed in the hope that it will be useful,
|
|
Packit Service |
19f098 |
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
Packit Service |
19f098 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
Packit Service |
19f098 |
Lesser General Public License for more details.
|
|
Packit Service |
19f098 |
|
|
Packit Service |
19f098 |
You should have received a copy of the GNU Lesser General Public
|
|
Packit Service |
19f098 |
License along with the GNU C Library; if not, see
|
|
Packit Service |
19f098 |
<http://www.gnu.org/licenses/>. */
|
|
Packit Service |
19f098 |
|
|
Packit Service |
19f098 |
/* This test attempts to open the (otherwise unrelated) PIE test
|
|
Packit Service |
19f098 |
program elf/tst-pie1 and expects the attempt to fail. */
|
|
Packit Service |
19f098 |
|
|
Packit Service |
19f098 |
#include <dlfcn.h>
|
|
Packit Service |
19f098 |
#include <stddef.h>
|
|
Packit Service |
19f098 |
#include <string.h>
|
|
Packit Service |
19f098 |
#include <support/check.h>
|
|
Packit Service |
19f098 |
#include <support/support.h>
|
|
Packit Service |
19f098 |
|
|
Packit Service |
19f098 |
static void
|
|
Packit Service |
19f098 |
test_mode (int mode)
|
|
Packit Service |
19f098 |
{
|
|
Packit Service |
19f098 |
char *pie_path = xasprintf ("%s/elf/tst-pie1", support_objdir_root);
|
|
Packit Service |
19f098 |
if (dlopen (pie_path, mode) != NULL)
|
|
Packit Service |
19f098 |
FAIL_EXIT1 ("dlopen succeeded unexpectedly (%d)", mode);
|
|
Packit Service |
19f098 |
const char *message = dlerror ();
|
|
Packit Service |
19f098 |
const char *expected
|
|
Packit Service |
19f098 |
= "cannot dynamically load position-independent executable";
|
|
Packit Service |
19f098 |
if (strstr (message, expected) == NULL)
|
|
Packit Service |
19f098 |
FAIL_EXIT1 ("unexpected error message (mode %d): %s", mode, message);
|
|
Packit Service |
19f098 |
}
|
|
Packit Service |
19f098 |
|
|
Packit Service |
19f098 |
static int
|
|
Packit Service |
19f098 |
do_test (void)
|
|
Packit Service |
19f098 |
{
|
|
Packit Service |
19f098 |
test_mode (RTLD_LAZY);
|
|
Packit Service |
19f098 |
test_mode (RTLD_NOW);
|
|
Packit Service |
19f098 |
return 0;
|
|
Packit Service |
19f098 |
}
|
|
Packit Service |
19f098 |
|
|
Packit Service |
19f098 |
#include <support/test-driver.c>
|