Skip to content

Commit

Permalink
[WRAPPERHELPER] Added box32 and line number support in the wrapperhelper
Browse files Browse the repository at this point in the history
  • Loading branch information
rajdakin committed Sep 30, 2024
1 parent f7d7fbb commit 9f7dbc7
Show file tree
Hide file tree
Showing 20 changed files with 3,626 additions and 1,771 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ backup/
/wrapperhelper/sanundefined
/wrapperhelper/src/machine.gen
/wrapperhelper/*.h
!/wrapperhelper/example-libc.h

# macOS
.DS_Store
15 changes: 6 additions & 9 deletions wrapperhelper/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@ To use the wrapper helper, run the following command in the folder containing th
bin/wrapperhelper -I/path/to/system/include "path_to_support_file" "path_to_private.h" "path_to_private.h"
```

You may add as many `-I` options as needed.
You may add as many `-I` options as needed. The folders `include-override/<arch>` and `include-override/common` are always prioritized, as if they appeared first in the command line.

You may also use the `-32` and `-64` switches to generate `box32` or `box64` files respectively. Alterately, you can use the `--emu arch` and `--target arch` options to select more precisely the emlated and executing platforms, though only `x86`, `x86_64` and `aarch64` are supported for now. By default, everything is as if `-64` was supplied.

The first file is a `C` file containing every declaration required. The second file is the "requests" input. The third file is the output file, which may be a different file.

Expand Down Expand Up @@ -100,30 +102,25 @@ The reading and writing of the `_private.h` files is implemented in `generator.c

## Known issues

This project only works for `box64`; more work is required for this to be compatible with `box32`.

Only native structures are read. This means that the current version of `wrapperhelper` does not detect an issue when a structure has different members or alignments in two different architectures.

No checking of signatures under `#ifdef`s is made.

Line numbers are missing entirely. For most errors, the corresponding file is not written with the error message.

Phase 5 is partially implemented, but could be greatly improved.

The following features are missing from the generator:
- Large structures as a parameter
- Large structure as a return type (more than 16 bytes)
- Structures with at least two elements as a parameter
- Large structure as a return type (more than 16 bytes on 64bits, or 8 bytes on 32bits)
- Atomic types

The following features are missing from the preprocessor:
- General token concatenation (though the concatenation of two `PTOK_IDENT` works without issue)
- Stringify
- Skipped unexpected token warnings
- Proper out-of-memory error handling

The following features are missing from the parser:
- `_Atomic(type-name)`
- `_Alignas(type-name)` and `_Alignas(constant-expression)`
- `(type-name){initializer-list}`
- Old style function declarations
- Function definitions are ignored, not parsed
- Attributes are ignored everywhere (with a `#define __attribute__(_)`)
8 changes: 4 additions & 4 deletions wrapperhelper/include-override/aarch64/stdc-predef.h
Original file line number Diff line number Diff line change
Expand Up @@ -123,16 +123,16 @@
//#define __BITINT_MAXWIDTH__ 65535
//#define __CHAR16_TYPE__ short unsigned int
//#define __CHAR32_TYPE__ unsigned int
#define __INT8_C(c) c
//#define __INT8_C(c) c
#define __INT8_MAX__ 0x7f
//#define __INT8_TYPE__ signed char
#define __INT16_C(c) c
//#define __INT16_C(c) c
#define __INT16_MAX__ 0x7fff
//#define __INT16_TYPE__ short int
#define __INT32_C(c) c
//#define __INT32_C(c) c
#define __INT32_MAX__ 0x7fffffff
//#define __INT32_TYPE__ int
#define __INT64_C(c) c ## L
//#define __INT64_C(c) c ## L
#define __INT64_MAX__ 0x7fffffffffffffffL
//#define __INT64_TYPE__ long int
#define __INT_FAST8_MAX__ 0x7f
Expand Down
2 changes: 0 additions & 2 deletions wrapperhelper/include-override/common/stdc-predef.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,2 @@
// Ignore all attributes
#define __attribute__(_)

#include_next "stdc-predef.h"
55 changes: 55 additions & 0 deletions wrapperhelper/include-override/x86/bits/pthreadtypes-arch.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
/* Copyright (C) 2002-2024 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; if not, see
<https://www.gnu.org/licenses/>. */

#ifndef _BITS_PTHREADTYPES_ARCH_H
#define _BITS_PTHREADTYPES_ARCH_H 1

#include <bits/wordsize.h>

#ifdef __x86_64__
# if __WORDSIZE == 64
# define __SIZEOF_PTHREAD_MUTEX_T 40
# define __SIZEOF_PTHREAD_ATTR_T 56
# define __SIZEOF_PTHREAD_RWLOCK_T 56
# define __SIZEOF_PTHREAD_BARRIER_T 32
# else
# define __SIZEOF_PTHREAD_MUTEX_T 32
# define __SIZEOF_PTHREAD_ATTR_T 32
# define __SIZEOF_PTHREAD_RWLOCK_T 44
# define __SIZEOF_PTHREAD_BARRIER_T 20
# endif
#else
# define __SIZEOF_PTHREAD_MUTEX_T 24
# define __SIZEOF_PTHREAD_ATTR_T 36
# define __SIZEOF_PTHREAD_RWLOCK_T 32
# define __SIZEOF_PTHREAD_BARRIER_T 20
#endif
#define __SIZEOF_PTHREAD_MUTEXATTR_T 4
#define __SIZEOF_PTHREAD_COND_T 48
#define __SIZEOF_PTHREAD_CONDATTR_T 4
#define __SIZEOF_PTHREAD_RWLOCKATTR_T 8
#define __SIZEOF_PTHREAD_BARRIERATTR_T 4

#define __LOCK_ALIGNMENT
#define __ONCE_ALIGNMENT

#ifndef __x86_64__
/* Extra attributes for the cleanup functions. */
# define __cleanup_fct_attribute __attribute__ ((__regparm__ (1)))
#endif

#endif /* bits/pthreadtypes.h */
Loading

0 comments on commit 9f7dbc7

Please sign in to comment.