binutils-gdb/ld/testsuite/ld-elf/pr23428.c
Alan Modra 07e7fdfd42 Use __asm__ rather than asm in ld testsuite
* testsuite/ld-elf/pr23428.c: Define _DEFAULT_SOURCE.
	* testsuite/ld-elf/indirect1b.c: Replace asm with __asm__.
	* testsuite/ld-elf/indirect2.c: Likewise.
	* testsuite/ld-elf/indirect3b.c: Likewise.
	* testsuite/ld-elf/indirect4b.c: Likewise.
	* testsuite/ld-elf/pr14323-2.c: Likewise.
	* testsuite/ld-elf/pr18720b.c: Likewise.
	* testsuite/ld-elf/pr23428.c: Likewise.
	* testsuite/ld-elfvsb/common.c: Likewise.
	* testsuite/ld-elfvsb/main.c: Likewise.
	* testsuite/ld-elfvsb/sh1.c: Likewise.
	* testsuite/ld-elfvsb/test.c: Likewise.
	* testsuite/ld-pe/aligncomm-1.c: Likewise.
	* testsuite/ld-pe/aligncomm-2.c: Likewise.
	* testsuite/ld-pe/aligncomm-3.c: Likewise.
	* testsuite/ld-pe/aligncomm-4.c: Likewise.
	* testsuite/ld-plugin/pr23958.c: Likewise.
	* testsuite/ld-size/size-1b.c: Likewise.
	* testsuite/ld-size/size-2b.c: Likewise.
	* testsuite/ld-size/size-3a.c: Likewise.
	* testsuite/ld-size/size-3b.c: Likewise.
	* testsuite/ld-size/size-3c.c: Likewise.
	* testsuite/ld-size/size-4b.c: Likewise.
	* testsuite/ld-size/size-5b.c: Likewise.
	* testsuite/ld-size/size-6a.c: Likewise.
	* testsuite/ld-size/size-7a.c: Likewise.
	* testsuite/ld-size/size-8a.c: Likewise.
	* testsuite/ld-size/size-9b.c: Likewise.
	* testsuite/ld-size/size-10b.c: Likewise.
2020-06-16 22:13:20 +09:30

47 lines
854 B
C

/* Ensure we get syscall declared. */
#define _DEFAULT_SOURCE
#include <unistd.h>
#include <link.h>
#include <syscall.h>
#define STRING_COMMA_LEN(STR) (STR), (sizeof (STR) - 1)
int
main (int argc, char **argv)
{
char **ev = &argv[argc + 1];
char **evp = ev;
ElfW(auxv_t) *av;
const ElfW(Phdr) *phdr = NULL;
size_t phnum = 0;
size_t loadnum = 0;
int fd = STDOUT_FILENO;
size_t i;
while (*evp++ != NULL)
;
av = (ElfW(auxv_t) *) evp;
for (; av->a_type != AT_NULL; ++av)
switch (av->a_type)
{
case AT_PHDR:
phdr = (const void *) av->a_un.a_val;
break;
case AT_PHNUM:
phnum = av->a_un.a_val;
break;
}
for (i = 0; i < phnum; i++, phdr++)
if (phdr->p_type == PT_LOAD)
loadnum++;
syscall (SYS_write, fd, STRING_COMMA_LEN ("PASS\n"));
syscall (SYS_exit, !loadnum);
return 0;
}