https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=293370

            Bug ID: 293370
           Summary: elf_aux_info(3): returns ENOENT for AT_HWCAP(2)
           Product: Base System
           Version: 15.0-RELEASE
          Hardware: Any
                OS: Any
            Status: New
          Severity: Affects Some People
          Priority: ---
         Component: misc
          Assignee: [email protected]
          Reporter: [email protected]

Found via bug 292864. For usage example in port see CPP/Windows/SystemInfo.cpp
("Windows/SystemInfo.cpp" does not mean WIN32 for 7z), or the following
(reproducible in FreeBSD-15.0-RELEASE-amd64-ufs.raw VM image):

Linux getauxval(3):
RETURN VALUE
       On success, getauxval() returns the value corresponding to type.  If
       type is not found, 0 is returned.

FreeBSD elf_aux_info(3):
RETURN VALUES
     Returns zero on success, or an error number on failure.

example.c:

#include <sys/auxv.h>
#include <stdio.h>
#include <string.h>

#if defined(__FreeBSD__)
static unsigned long
MY_getauxval(int aux)
{
        int err;
        unsigned long val;

        err = elf_aux_info(aux, &val, sizeof(val));
        if (err) {
                printf("elf_aux_info: %s\n", strerror(err));
                val = 0;        /* 7-zip wraps in MY_getauxval
                                        then returns 0 on failure */
        }

        return (val);
}
#elif defined(__linux__)
#define MY_getauxval getauxval
#endif

int
main(void)
{
        unsigned long h;

        h = MY_getauxval(AT_HWCAP);
        printf("hwcap:%lx\n", h);
        h = MY_getauxval(AT_HWCAP2);
        if (h != 0)
                printf("hwcap2:%lx\n", h);

        return (0);
}

@debian13:~$ cc example.c && ./a.out
hwcap:2
hwcap2:2

@freebsd15:~ $ cc example.c && ./a.out
elf_aux_info(): No such file or directory
hwcap:0
elf_aux_info(): No such file or directory

-- 
You are receiving this mail because:
You are the assignee for the bug.

Reply via email to