mirror of
https://github.com/cirosantilli/linux-kernel-module-cheat.git
synced 2026-01-23 02:05:57 +01:00
glibc: update to 6c99e37f6fb640a50a3113b2dbee5d5389843c1e
Initializes the submodule.
This commit is contained in:
3
.gitmodules
vendored
3
.gitmodules
vendored
@@ -27,3 +27,6 @@
|
|||||||
[submodule "submodules/boot-wrapper-aarch64"]
|
[submodule "submodules/boot-wrapper-aarch64"]
|
||||||
path = submodules/boot-wrapper-aarch64
|
path = submodules/boot-wrapper-aarch64
|
||||||
url = git://git.kernel.org/pub/scm/linux/kernel/git/mark/boot-wrapper-aarch64.git
|
url = git://git.kernel.org/pub/scm/linux/kernel/git/mark/boot-wrapper-aarch64.git
|
||||||
|
[submodule "submodules/glibc"]
|
||||||
|
path = submodules/glibc
|
||||||
|
url = https://github.com/cirosantilli/glibc
|
||||||
|
|||||||
60
README.adoc
60
README.adoc
@@ -303,6 +303,66 @@ If you really want to develop semiconductors, your only choice is to join an uni
|
|||||||
|
|
||||||
While hacking QEMU, you will likely want to GDB step its source. That is trivial since QEMU is just another userland program like any other, but our setup has a shortcut to make it even more convenient, see: <<debug-the-emulator>>.
|
While hacking QEMU, you will likely want to GDB step its source. That is trivial since QEMU is just another userland program like any other, but our setup has a shortcut to make it even more convenient, see: <<debug-the-emulator>>.
|
||||||
|
|
||||||
|
===== Your first glibc hack
|
||||||
|
|
||||||
|
We use <<libc-choice,glibc as our default libc now>>, and it is tracked as an unmodified submodule at link:submodules/glibc[], at the exact same version that Buildroot has it, which can be found at: link:https://github.com/buildroot/buildroot/blob/2018.05/package/glibc/glibc.mk#L13[package/glibc/glibc.mk]. Buildroot 2018.05 applies no patches.
|
||||||
|
|
||||||
|
Let's hack up the `puts` function:
|
||||||
|
|
||||||
|
....
|
||||||
|
./build-buildroot -- glibc-reconfigure
|
||||||
|
....
|
||||||
|
|
||||||
|
with the patch:
|
||||||
|
|
||||||
|
....
|
||||||
|
diff --git a/libio/ioputs.c b/libio/ioputs.c
|
||||||
|
index 706b20b492..23185948f3 100644
|
||||||
|
--- a/libio/ioputs.c
|
||||||
|
+++ b/libio/ioputs.c
|
||||||
|
@@ -38,8 +38,9 @@ _IO_puts (const char *str)
|
||||||
|
if ((_IO_vtable_offset (_IO_stdout) != 0
|
||||||
|
|| _IO_fwide (_IO_stdout, -1) == -1)
|
||||||
|
&& _IO_sputn (_IO_stdout, str, len) == len
|
||||||
|
+ && _IO_sputn (_IO_stdout, " hacked", 7) == 7
|
||||||
|
&& _IO_putc_unlocked ('\n', _IO_stdout) != EOF)
|
||||||
|
- result = MIN (INT_MAX, len + 1);
|
||||||
|
+ result = MIN (INT_MAX, len + 1 + 7);
|
||||||
|
|
||||||
|
_IO_release_lock (_IO_stdout);
|
||||||
|
return result;
|
||||||
|
....
|
||||||
|
|
||||||
|
And then:
|
||||||
|
|
||||||
|
....
|
||||||
|
./run --eval-after '/hello.out'
|
||||||
|
....
|
||||||
|
|
||||||
|
outputs:
|
||||||
|
|
||||||
|
....
|
||||||
|
hello hacked
|
||||||
|
....
|
||||||
|
|
||||||
|
Lol!
|
||||||
|
|
||||||
|
We can also test our hacked glibc on <<user-mode-simulation>> with:
|
||||||
|
|
||||||
|
....
|
||||||
|
./run --userland hello
|
||||||
|
....
|
||||||
|
|
||||||
|
I just noticed that this is actually a good way to develop glibc for other archs.
|
||||||
|
|
||||||
|
Note that for arch agnostic features that don't rely on bleeding kernel changes that you host doesn't yet have, you can develop glibc natively as explained at:
|
||||||
|
|
||||||
|
* https://stackoverflow.com/questions/10412684/how-to-compile-my-own-glibc-c-standard-library-from-source-and-use-it/52454710#52454710
|
||||||
|
* https://stackoverflow.com/questions/847179/multiple-glibc-libraries-on-a-single-host/52454603#52454603
|
||||||
|
* https://stackoverflow.com/questions/2856438/how-can-i-link-to-a-specific-glibc-version/52550158#52550158 more focus on symbol versioning, but no one knows how to do it, so I answered
|
||||||
|
|
||||||
|
Tested on a30ed0f047523ff2368d421ee2cce0800682c44e + 1.
|
||||||
|
|
||||||
==== About the QEMU Buildroot setup
|
==== About the QEMU Buildroot setup
|
||||||
|
|
||||||
This is our reference setup, and the best supported one, use it unless you have good reason not to.
|
This is our reference setup, and the best supported one, use it unless you have good reason not to.
|
||||||
|
|||||||
7
build
7
build
@@ -107,7 +107,12 @@ so looping over all of them would waste time.
|
|||||||
)
|
)
|
||||||
buildroot_component = _Component(
|
buildroot_component = _Component(
|
||||||
self._build_file('build-buildroot'),
|
self._build_file('build-buildroot'),
|
||||||
submodules = {'buildroot'},
|
submodules = {
|
||||||
|
'buildroot',
|
||||||
|
},
|
||||||
|
submodules_shallow = {
|
||||||
|
'glibc',
|
||||||
|
},
|
||||||
# https://buildroot.org/downloads/manual/manual.html#requirement
|
# https://buildroot.org/downloads/manual/manual.html#requirement
|
||||||
apt_get_pkgs={
|
apt_get_pkgs={
|
||||||
'bash',
|
'bash',
|
||||||
|
|||||||
@@ -1,2 +1,3 @@
|
|||||||
LINUX_OVERRIDE_SRCDIR = ../../submodules/linux
|
LINUX_OVERRIDE_SRCDIR = ../../submodules/linux
|
||||||
QEMU_OVERRIDE_SRCDIR = ../../submodules/qemu
|
QEMU_OVERRIDE_SRCDIR = ../../submodules/qemu
|
||||||
|
GLIBC_OVERRIDE_SRCDIR = ../../submodules/glibc
|
||||||
|
|||||||
1
submodules/glibc
Submodule
1
submodules/glibc
Submodule
Submodule submodules/glibc added at 6c99e37f6f
Reference in New Issue
Block a user