Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
eld
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
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
or1k
eld
Commits
5487e7bb
Commit
5487e7bb
authored
10 years ago
by
Alessandro Di Federico
Browse files
Options
Downloads
Patches
Plain Diff
libmy: use functions from the main executable
parent
9dae0f5b
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
CMakeLists.txt
+13
-1
13 additions, 1 deletion
CMakeLists.txt
libmy.c
+7
-1
7 additions, 1 deletion
libmy.c
shared-library-id.bin
+0
-0
0 additions, 0 deletions
shared-library-id.bin
with
20 additions
and
2 deletions
CMakeLists.txt
+
13
−
1
View file @
5487e7bb
...
...
@@ -55,12 +55,21 @@ add_custom_command(
add_custom_target
(
libmy_header
DEPENDS
${
CMAKE_CURRENT_BINARY_DIR
}
/libmy.so.h
)
# libyour.so
# Create a copy of the loader executable forcing it to a shared object
# so it can be dynamically linked against other shared libraries
add_custom_command
(
OUTPUT
${
CMAKE_CURRENT_BINARY_DIR
}
/libyour.so.h
COMMAND xxd -i libyour.so > libyour.so.h
DEPENDS
${
CMAKE_CURRENT_BINARY_DIR
}
/libyour.so
)
add_custom_command
(
TARGET loader
POST_BUILD
COMMAND
${
CMAKE_COMMAND
}
-E copy
${
CMAKE_CURRENT_BINARY_DIR
}
/loader
${
CMAKE_CURRENT_BINARY_DIR
}
/main
COMMAND dd if=
${
CMAKE_CURRENT_SOURCE_DIR
}
/shared-library-id.bin
of=main seek=16 bs=1 conv=notrunc
)
add_custom_target
(
libyour_header
DEPENDS
${
CMAKE_CURRENT_BINARY_DIR
}
/libyour.so.h
)
...
...
@@ -74,6 +83,9 @@ add_library(eld STATIC dl.c eld.c elf-object.c)
# Loader main executable
add_executable
(
loader test.c
)
target_link_libraries
(
loader eld
)
# Link libmy against libyour and the main executable
target_link_libraries
(
my your
":main"
)
add_dependencies
(
my loader
)
# Simulation targets
add_custom_target
(
loader_sim COMMAND
${
OR1K_SIM_PATH
}
-f sim.cfg loader
)
...
...
This diff is collapsed.
Click to expand it.
libmy.c
+
7
−
1
View file @
5487e7bb
#include
<stdio.h>
static
int
counter
=
42
;
extern
int
your
();
extern
void
print
(
int
value
);
__attribute__
((
constructor
))
int
my
()
{
...
...
@@ -9,5 +12,8 @@ int my() {
__attribute__
((
destructor
))
void
finalization
()
{
counter
=
0
;
print
(
counter
);
// This should be in the main executable
printf
(
"0x%x
\n
"
,
counter
);
}
This diff is collapsed.
Click to expand it.
shared-library-id.bin
0 → 100644
+
0
−
0
View file @
5487e7bb
File added
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