-
Notifications
You must be signed in to change notification settings - Fork 40
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add iputils static PIE build #87
base: master
Are you sure you want to change the base?
Changes from all commits
2de5416
61fe6bc
9815ea4
759982d
0490b28
18a9fe9
7b5c3dc
54f6e50
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
/iputils-* | ||
/*.tar.gz |
Original file line number | Diff line number | Diff line change | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,65 @@ | ||||||||||||
# iputils | ||||||||||||
|
||||||||||||
Build the [iputils](https://github.com/iputils/iputils/) set of tools as static PIE ELF binaries running on Linux. | ||||||||||||
|
||||||||||||
## Requirements | ||||||||||||
|
||||||||||||
Make sure the following packages are installed: | ||||||||||||
* gcc >= 8 (required for the `-static-pie` linking option) | ||||||||||||
* autotools | ||||||||||||
* meson | ||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||
* GNU Make | ||||||||||||
|
||||||||||||
For Debian, run the command below to install all requirements: | ||||||||||||
|
||||||||||||
```bash | ||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||
$ sudo apt install build-essential | ||||||||||||
export DEBIAN_FRONTEND="noninteractive" | ||||||||||||
|
||||||||||||
apt update | ||||||||||||
|
||||||||||||
apt install -y --no-install-recommends \ | ||||||||||||
clang \ | ||||||||||||
docbook-xsl-ns \ | ||||||||||||
file \ | ||||||||||||
gcc \ | ||||||||||||
gettext \ | ||||||||||||
iproute2 \ | ||||||||||||
libcap-dev \ | ||||||||||||
libidn2-0-dev \ | ||||||||||||
libssl-dev \ | ||||||||||||
make \ | ||||||||||||
meson \ | ||||||||||||
pkg-config \ | ||||||||||||
xsltproc | ||||||||||||
|
||||||||||||
``` | ||||||||||||
|
||||||||||||
## Building | ||||||||||||
|
||||||||||||
The static PIE ELF file are located in the current directory. | ||||||||||||
If you want to rebuild them, run: | ||||||||||||
|
||||||||||||
```bash | ||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||
$ ./build.sh | ||||||||||||
``` | ||||||||||||
|
||||||||||||
This script downloads, unpacks, patches, configures and builds the tools. | ||||||||||||
|
||||||||||||
## Running | ||||||||||||
|
||||||||||||
The resulting binaries can be used as is. | ||||||||||||
For example, you can ping an address by issuing the command: | ||||||||||||
|
||||||||||||
```bash | ||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||
$ ./ping 1.1.1.1 | ||||||||||||
``` | ||||||||||||
|
||||||||||||
## Issues | ||||||||||||
|
||||||||||||
1. When running in KVM with LWIP you can't use RAW sockets because they're not | ||||||||||||
available by default. See this for more information: | ||||||||||||
https://github.com/unikraft/lib-lwip/pull/2 | ||||||||||||
Comment on lines
+60
to
+62
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||
|
||||||||||||
2. There is a bug in LWIP where normal sockets (not RAW) that use ICMP protocol | ||||||||||||
are sent using UDP protocol instead. See https://github.com/unikraft/lib-lwip/issues/32 | ||||||||||||
Comment on lines
+64
to
+65
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
#!/bin/bash | ||
|
||
|
||
BUILD_VERSION=20221126 | ||
# Clean up. | ||
rm -fr iputils-* | ||
rm -fr *.tar.gz | ||
|
||
echo -n "Downloading iputils ... " | ||
wget -O "${BUILD_VERSION}.tar.gz" -q https://github.com/iputils/iputils/archive/refs/tags/${BUILD_VERSION}.tar.gz | ||
echo "" | ||
|
||
echo -n "Unpacking iputils ... " | ||
tar xzf "${BUILD_VERSION}.tar.gz" | ||
echo "" | ||
|
||
SOURCE_DIR="iputils-${BUILD_VERSION}" | ||
pushd "${SOURCE_DIR}" > /dev/null 2>&1 | ||
|
||
echo "Patching iputils files ... " | ||
patch < ../iputils.patch | ||
echo "" | ||
|
||
echo "Building ... " | ||
./configure --prefix=. | ||
make | ||
|
||
popd > /dev/null 2>&1 | ||
|
||
ln -fn "${SOURCE_DIR}/builddir/ping/ping" . | ||
ln -fn "${SOURCE_DIR}/builddir/arping" . | ||
ln -fn "${SOURCE_DIR}/builddir/tracepath" . | ||
ln -fn "${SOURCE_DIR}/builddir/clockdiff" . |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
--- configure 2022-11-26 01:07:21.000000000 +0200 | ||
+++ configure 2023-03-31 12:40:52.167300078 +0300 | ||
@@ -1,14 +1,16 @@ | ||
#!/bin/sh | ||
|
||
DIR=builddir | ||
|
||
+export LDFLAGS="-static-pie" | ||
+ | ||
echo "Using './$DIR' as the directory for build output" | ||
echo | ||
|
||
if [ $# -ne 0 ]; then | ||
meson configure $DIR | ||
echo | ||
echo 'Configuration can be changed like this:' | ||
echo " meson configure $DIR -Dprefix=/usr" | ||
echo ' More info: http://mesonbuild.com/Configuring-a-build-directory.html' | ||
# See also: http://mesonbuild.com/howtox.html | ||
--- meson.build 2022-11-26 01:07:21.000000000 +0200 | ||
+++ meson.build 2023-03-31 12:41:28.679222461 +0300 | ||
@@ -1,32 +1,37 @@ | ||
# Copyright (c) Iputils Project, 2017-2021 | ||
|
||
project('iputils', 'c', | ||
default_options : [ | ||
'c_std=c99', | ||
'warning_level=3', | ||
'localstatedir=var', | ||
+ 'USE_IDN=false', | ||
], | ||
meson_version : '>=0.40', | ||
version : '20221126') # keep in sync with: git describe | awk -F- '{print $1}' | ||
|
||
cc = meson.get_compiler('c') | ||
|
||
add_project_arguments( | ||
+ '-fPIC', | ||
'-include', 'config.h', | ||
'-include', 'git-version.h', | ||
language : 'c' | ||
) | ||
|
||
conf = configuration_data() | ||
conf.set_quoted('PACKAGE_NAME', meson.project_name()) | ||
|
||
+conf.set('prefer_static', true) | ||
+conf.set('default_library', 'static') | ||
+ | ||
build_arping = get_option('BUILD_ARPING') | ||
build_clockdiff = get_option('BUILD_CLOCKDIFF') | ||
build_ping = get_option('BUILD_PING') | ||
build_tracepath = get_option('BUILD_TRACEPATH') | ||
|
||
build_mans = get_option('BUILD_MANS') | ||
build_html_mans = get_option('BUILD_HTML_MANS') | ||
run_tests = not get_option('SKIP_TESTS') | ||
|
||
prefix = get_option('prefix') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.