Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
N
nettle
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Nettle
nettle
Commits
29d6dacf
Commit
29d6dacf
authored
10 years ago
by
Niels Möller
Browse files
Options
Downloads
Patches
Plain Diff
Make constructor hack less gcc-specific.
parent
aa7ad293
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
ChangeLog
+6
-0
6 additions, 0 deletions
ChangeLog
x86_64/fat/fat.c
+14
-16
14 additions, 16 deletions
x86_64/fat/fat.c
with
20 additions
and
16 deletions
ChangeLog
+
6
−
0
View file @
29d6dacf
2015-01-13 Niels Möller <nisse@lysator.liu.se>
2015-01-13 Niels Möller <nisse@lysator.liu.se>
* x86_64/fat/fat.c: For constructor hack, check
HAVE_GCC_ATTRIBUTE, not __GNUC__. Also support sun compilers, as
suggested by Nikos Mavrogiannopoulos, and attch the constructor
attribute directly to fat_init.
(fat_constructor): Deleted wrapper function.
* x86_64/fat/fat.c: New file, initialization for x86_64 fat
* x86_64/fat/fat.c: New file, initialization for x86_64 fat
library.
library.
...
...
This diff is collapsed.
Click to expand it.
x86_64/fat/fat.c
+
14
−
16
View file @
29d6dacf
...
@@ -53,22 +53,21 @@
...
@@ -53,22 +53,21 @@
To get everything hooked in, we use a belt-and-suspenders approach.
To get everything hooked in, we use a belt-and-suspenders approach.
When compiling with gcc, we try to register a constructor function
We try to register fat_init as a constructor function to be called
which calls fat_init as soon as the library is loaded. If this is
at load time. If this is unavailable or non-working, we instead
unavailable or non-working, we instead arrange fat_init to be
arrange fat_init to be called lazily.
called on demand.
For the actual indirection, there are two cases.
For the actual indirection, there are two cases.
If ifunc support is available, function pointers are statically
If ifunc support is available, function pointers are statically
initialized to NULL, and we register resolver functions, e.g.,
initialized to NULL, and we register resolver functions, e.g.,
_aes_encrypt_resolve, which call
s
fat_init, and then return
s
the
_aes_encrypt_resolve, which call fat_init, and then return the
function pointer, e.g., the value of _aes_encrypt_vec.
function pointer, e.g., the value of _aes_encrypt_vec.
If ifunc is not available, we have to define a wrapper function to
If ifunc is not available, we have to define a wrapper function to
jump via the function pointer. (FIXME: For internal calls, we could
jump via the function pointer. (FIXME: For internal calls, we could
do this as a macro
instead
). We statically initialize each function
do this as a macro). We statically initialize each function
pointer
pointer
to point to a special initialization function, e.g.,
to point to a special initialization function, e.g.,
_aes_encrypt_init, which calls fat_init, and then invokes the right
_aes_encrypt_init, which calls fat_init, and then invokes the right
function. This way, all pointers are setup correctly at the first
function. This way, all pointers are setup correctly at the first
call to any fat function.
call to any fat function.
...
@@ -80,6 +79,13 @@
...
@@ -80,6 +79,13 @@
# define IFUNC(resolve)
# define IFUNC(resolve)
#endif
#endif
#if HAVE_GCC_ATTRIBUTE
# define CONSTRUCTOR __attribute__ ((constructor))
#elif defined (__sun)
# pragma init(fat_init)
# define CONSTRUCTOR
#endif
void
_nettle_cpuid
(
uint32_t
input
,
uint32_t
regs
[
4
]);
void
_nettle_cpuid
(
uint32_t
input
,
uint32_t
regs
[
4
]);
typedef
void
void_func
(
void
);
typedef
void
void_func
(
void
);
...
@@ -111,7 +117,7 @@ static aes_crypt_internal_func *_aes_decrypt_vec = _aes_decrypt_init;
...
@@ -111,7 +117,7 @@ static aes_crypt_internal_func *_aes_decrypt_vec = _aes_decrypt_init;
it is idempotent, and on x86, pointer updates are atomic, so
it is idempotent, and on x86, pointer updates are atomic, so
there's no danger if it is called simultaneously from multiple
there's no danger if it is called simultaneously from multiple
threads. */
threads. */
static
void
static
void
CONSTRUCTOR
fat_init
(
void
)
fat_init
(
void
)
{
{
static
volatile
int
initialized
=
0
;
static
volatile
int
initialized
=
0
;
...
@@ -151,14 +157,6 @@ fat_init (void)
...
@@ -151,14 +157,6 @@ fat_init (void)
initialized
=
1
;
initialized
=
1
;
}
}
#if __GNUC__
static
void
__attribute__
((
constructor
))
fat_constructor
(
void
)
{
fat_init
();
}
#endif
#if HAVE_LINK_IFUNC
#if HAVE_LINK_IFUNC
static
void_func
*
static
void_func
*
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment