From 3652674af6a72d3d1a37f667e6c8ad97aca2f535 Mon Sep 17 00:00:00 2001 From: Henrik Grimler Date: Mon, 20 Jul 2020 21:35:33 +0200 Subject: [PATCH] ctypes-sh: update to 1.2 --- .../002-array-element-fix-from-pahole.patch | 113 ------------------ packages/ctypes-sh/build.sh | 5 +- packages/ctypes-sh/compile-obstack-c.patch | 10 +- 3 files changed, 6 insertions(+), 122 deletions(-) delete mode 100644 packages/ctypes-sh/002-array-element-fix-from-pahole.patch diff --git a/packages/ctypes-sh/002-array-element-fix-from-pahole.patch b/packages/ctypes-sh/002-array-element-fix-from-pahole.patch deleted file mode 100644 index 4258ffe1c..000000000 --- a/packages/ctypes-sh/002-array-element-fix-from-pahole.patch +++ /dev/null @@ -1,113 +0,0 @@ -From eb6bd05766f54dc921018de1f93fcfa290e4a19d Mon Sep 17 00:00:00 2001 -From: Yonghong Song -Date: Thu, 23 Aug 2018 14:04:13 -0700 -Subject: [PATCH] dwarf_loader: Process DW_AT_count in DW_TAG_subrange_type - -For array type, gcc and clang generates dwarf info with different tags. For -example, with existing pahole, - - $ cat test.c - int a[5][5]; - $ gcc -c -g test.c - $ llvm-dwarfdump test.o - ... - 0x0000001d: DW_TAG_array_type - DW_AT_type (0x0000003a "int") - DW_AT_sibling (0x00000033) - - 0x00000026: DW_TAG_subrange_type - DW_AT_type (0x00000033 "long unsigned int") - DW_AT_upper_bound (0x04) - - 0x0000002c: DW_TAG_subrange_type - DW_AT_type (0x00000033 "long unsigned int") - DW_AT_upper_bound (0x04) - $ pahole -JV test.o - [1] ARRAY (anon) type_id=3 index_type_id=3 nr_elems=25 - [2] INT long unsigned int size=8 bit_offset=0 nr_bits=64 encoding=(none) - [3] INT int size=4 bit_offset=0 nr_bits=32 encoding=SIGNED - $ clang -c -g test.c - $ llvm-dwarfdump test.o - ... - 0x00000033: DW_TAG_array_type - DW_AT_type (0x00000045 "int") - - 0x00000038: DW_TAG_subrange_type - DW_AT_type (0x0000004c "__ARRAY_SIZE_TYPE__") - DW_AT_count (0x05) - - 0x0000003e: DW_TAG_subrange_type - DW_AT_type (0x0000004c "__ARRAY_SIZE_TYPE__") - DW_AT_count (0x05) - $ pahole -JV test.o - [1] ARRAY (anon) type_id=2 index_type_id=2 nr_elems=0 - [2] INT int size=4 bit_offset=0 nr_bits=32 encoding=SIGNED - [3] INT __ARRAY_SIZE_TYPE__ size=8 bit_offset=0 nr_bits=64 encoding=(none) - -Current pahole processed DW_AT_upper_bound under DW_TAG_subrange_type to -get array range, but it did not process DW_AT_count so during pahole -dwarf2btf conversion, the flattened array size is 0. - -This patch fixed the issue by processing DW_AT_count properly. -With the change, for clang generated test.o, pahole btf conversion output is: - $ pahole -JV test.o - [1] ARRAY (anon) type_id=2 index_type_id=2 nr_elems=25 - [2] INT int size=4 bit_offset=0 nr_bits=32 encoding=SIGNED - [3] INT __ARRAY_SIZE_TYPE__ size=8 bit_offset=0 nr_bits=64 encoding=(none) - -Committer testing: - -Before: - - # pahole -C augmented_enter_connect_args augmented_syscalls.bpf.o - struct augmented_enter_connect_args { - struct syscall_enter_connect_args args; /* 0 40 */ - char addr[0]; /* 40 0 */ - - /* size: 56, cachelines: 1, members: 2 */ - /* padding: 16 */ - /* last cacheline: 56 bytes */ - }; - # file augmented_syscalls.bpf.o - augmented_syscalls.bpf.o: ELF 64-bit LSB relocatable, *unknown arch 0xf7* version 1 (SYSV), with debug_info, not stripped - # - -After: - - # pahole -C augmented_enter_connect_args augmented_syscalls.bpf.o - struct augmented_enter_connect_args { - struct syscall_enter_connect_args args; /* 0 40 */ - char addr[14]; /* 40 14 */ - - /* size: 56, cachelines: 1, members: 2 */ - /* padding: 2 */ - /* last cacheline: 56 bytes */ - }; - # - -Signed-off-by: Yonghong Song -Tested-by: Arnaldo Carvalho de Melo -Cc: Martin KaFai Lau -Cc: Okash Khawaja -Signed-off-by: Arnaldo Carvalho de Melo ---- - dwarf_loader.c | 6 ++++++ - 1 file changed, 6 insertions(+) - -diff --git a/src/struct/dwarf_loader.c b/src/struct/dwarf_loader.c -index 037e005..23dfdfb 100644 ---- a/src/struct/dwarf_loader.c -+++ b/src/struct/dwarf_loader.c -@@ -933,6 +933,12 @@ static uint64_t attr_upper_bound(Dwarf_Die *die) - if (dwarf_formudata(&attr, &num) == 0) { - return (uintmax_t)num + 1; - } -+ } else if (dwarf_attr(die, DW_AT_count, &attr) != NULL) { -+ Dwarf_Word num; -+ -+ if (dwarf_formudata(&attr, &num) == 0) { -+ return (uintmax_t)num; -+ } - } - - return 0; diff --git a/packages/ctypes-sh/build.sh b/packages/ctypes-sh/build.sh index 8393d3b6c..1a1d8a1e5 100644 --- a/packages/ctypes-sh/build.sh +++ b/packages/ctypes-sh/build.sh @@ -1,10 +1,9 @@ TERMUX_PKG_HOMEPAGE=https://github.com/taviso/ctypes.sh TERMUX_PKG_DESCRIPTION="A foreign function interface for bash" TERMUX_PKG_LICENSE="MIT" -TERMUX_PKG_VERSION=1.1 -TERMUX_PKG_REVISION=2 +TERMUX_PKG_VERSION=1.2 TERMUX_PKG_SRCURL=https://github.com/taviso/ctypes.sh/releases/download/v${TERMUX_PKG_VERSION}/ctypes-sh-${TERMUX_PKG_VERSION}.tar.gz -TERMUX_PKG_SHA256=f7c8276b556101c51838296560d152fdcd96b860254a38d216b92986f31f8297 +TERMUX_PKG_SHA256=8896334f5fa88f656057bff807ec6921c8f76fc6de801d996d2057fcb18b3a68 TERMUX_PKG_DEPENDS="bash, libelf, libdw, libffi, zlib" TERMUX_PKG_BUILD_IN_SRC=true diff --git a/packages/ctypes-sh/compile-obstack-c.patch b/packages/ctypes-sh/compile-obstack-c.patch index d44948975..c708e96e4 100644 --- a/packages/ctypes-sh/compile-obstack-c.patch +++ b/packages/ctypes-sh/compile-obstack-c.patch @@ -1,13 +1,11 @@ -diff --git a/src/Makefile.am b/src/Makefile.am -index 8a9b682..303f17f 100644 ---- a/src/Makefile.am -+++ b/src/Makefile.am -@@ -10,7 +10,7 @@ if ENABLE_STRUCTS +--- ./src/Makefile.am.orig 2020-07-20 19:30:45.535909736 +0000 ++++ ./src/Makefile.am 2020-07-20 19:32:50.544300161 +0000 +@@ -10,7 +10,7 @@ ctypes_la_LIBADD += libstruct.la noinst_LTLIBRARIES += libstruct.la noinst_HEADERS += struct/dutil.h struct/dwarves.h struct/elf_symtab.h struct/gobuffer.h struct/hash.h struct/list.h struct/rbtree.h struct/strings.h -libstruct_la_SOURCES = struct/dutil.c struct/dwarves.c struct/gobuffer.c struct/struct.c struct/strings.c struct/dwarf_loader.c struct/dwarves_fprintf.c struct/elf_symtab.c struct/rbtree.c +libstruct_la_SOURCES = ../lib/obstack.c struct/dutil.c struct/dwarves.c struct/gobuffer.c struct/struct.c struct/strings.c struct/dwarf_loader.c struct/dwarves_fprintf.c struct/elf_symtab.c struct/rbtree.c - libstruct_la_CFLAGS = -std=gnu99 -D_GNU_SOURCE + libstruct_la_CFLAGS = -std=gnu99 -D_GNU_SOURCE $(FFI_CFLAGS) libstruct_la_CPPFLAGS = -I../include -I../lib endif