From patchwork Mon Aug 3 09:51:30 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dodji Seketeli X-Patchwork-Id: 40199 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 28E503858D35; Mon, 3 Aug 2020 09:51:42 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 28E503858D35 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1596448302; bh=TjeOWSLPVtNinZ6oBl4ldzrkSf2nHgsgtk7ZPQ7a5Pg=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Help: List-Subscribe:From:Reply-To:From; b=sbcHUUtbAAWsDo4OBayrUCzDRsHeb+UL1goXEn1PVa0rshA/aD45tPtrf0IeIp3Dg jZIK30HWA/eLIOYFP7P05cwWmih0ThLUXaZXtJksICXIK+Ztq5k1ZFmFtJ7KnNnscT YuARIvALX4YvrjL1VDmiomJwe8FEh+EEO9nXWJv4= X-Original-To: libabigail@sourceware.org Delivered-To: libabigail@sourceware.org Received: from us-smtp-delivery-1.mimecast.com (us-smtp-1.mimecast.com [207.211.31.81]) by sourceware.org (Postfix) with ESMTP id 70CCA3858D35 for ; Mon, 3 Aug 2020 09:51:38 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 70CCA3858D35 Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-277-WWJVH5MeNCOyddzklYIRgw-1; Mon, 03 Aug 2020 05:51:35 -0400 X-MC-Unique: WWJVH5MeNCOyddzklYIRgw-1 Received: by mail-wr1-f72.google.com with SMTP id b13so8710147wrq.19 for ; Mon, 03 Aug 2020 02:51:35 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:organization:date:message-id :user-agent:mime-version; bh=TjeOWSLPVtNinZ6oBl4ldzrkSf2nHgsgtk7ZPQ7a5Pg=; b=hXmVRzhbGevdzEcrtG/U9ssuJFZJNl5bYW/dMPOPU2SrYNwgnsMVzvG2tbeXQ0PPP+ iHHCXkMNP9RwWrI5NfhxxvAQohs6ynWpXCT3epVqL0S1jm7ugZnj2MAVCt2D3TRqRoL4 0hY4K4J9tkB2b4AHMsNXVXF/MgagXJPxoe98zNlxjX5DLvp+GjxxaW7r8RjGG68ABPbR SLR0lZ0EbunOANFhpnK0Bu3NmRnEl3C55LgRn7uqgdUy7Oq6KEkolNoHzDh9HMzrkcC5 ahy/Yw45FGT3XMLsxKrl6MQKh8Ojh1g47qjC0SFGVs5QLW85SMYGVDeKU4pQsqldC4rZ mgNA== X-Gm-Message-State: AOAM533dshWCiLKu1gSbwTNELIRwwkprKKgDMyHHEuT0nyQd73ZSo+ie fU1ks8n+fgQTuiroa6gmoZRld1lvb30JeUw/2Nrt4G/KT/v8Hkt4cZxfxxfGWKUIM1egUPcnxqA ltkhaLSePeTumg1tuAygI X-Received: by 2002:adf:a192:: with SMTP id u18mr15939328wru.158.1596448293999; Mon, 03 Aug 2020 02:51:33 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxdKPx2L92lSgEF/aRmCgNLniSXFoOJWMlwizcVAEIZCKurTNOLSO34Q6gVfQm5sOPeStLfkg== X-Received: by 2002:adf:a192:: with SMTP id u18mr15939283wru.158.1596448293407; Mon, 03 Aug 2020 02:51:33 -0700 (PDT) Received: from localhost (91-166-131-130.subs.proxad.net. [91.166.131.130]) by smtp.gmail.com with ESMTPSA id j4sm9414346wmi.48.2020.08.03.02.51.31 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 03 Aug 2020 02:51:32 -0700 (PDT) Received: by localhost (Postfix, from userid 1000) id 84C5D18008D0; Mon, 3 Aug 2020 11:51:30 +0200 (CEST) To: libabigail@sourceware.org Subject: [PATCH] Bug 26261 - Fix logic for canonicalizing DW_TAG_subroutine_type DIEs Organization: Red Hat / France X-Operating-System: Red Hat Enterprise Linux Workstation 7.8 Beta X-URL: http://www.redhat.com Date: Mon, 03 Aug 2020 11:51:30 +0200 Message-ID: <873654f465.fsf@redhat.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-9.4 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: libabigail@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Mailing list of the Libabigail project List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-Patchwork-Original-From: Dodji Seketeli via Libabigail From: Dodji Seketeli Reply-To: Dodji Seketeli Errors-To: libabigail-bounces@sourceware.org Sender: "Libabigail" Hello, In the function compare_dies, the handling of DW_TAG_subroutine_type was unfinished. This DIE represents function types pointed-to by function pointer. It doesn't represent the type of a "real" function type like the abigail::ir::function_type would. The represent more an interface to a function, which a pointer can point to or which can be used to issue a call. So intended idea is that compare_dies compares two DIEs of the DW_TAG_subroutine_type and DW_TAG_subprogram kind (the later represents real function definitions) among other kinds, structurally, but by trying to optimize for speed, for the purpose of canonicalizing DIEs even before type canonicalization happens at the libabigail IR level. This is critical to save space (and time) by doing DIE de-duplication on huge binaries. This patch finishes to implement the comparison for DW_TAG_subroutine_type and comes with a carefully crafted test case that hits that code path. * src/abg-dwarf-reader.cc (compare_dies): Get out early if we are are in the middle of a potential recursive comparison of function types. Likewise if we detect that the two function types have different textual representations, linkage names, or have a the same textual representation, linkage names and are defined in the same translation unit. * tests/data/test-read-dwarf/PR26261/PR26261-exe: New test binary input file. * tests/data/test-read-dwarf/PR26261/PR26261-exe.abi: New reference test output file. * tests/data/test-read-dwarf/PR26261/PR26261-main.c: Source code of the binary above. * tests/data/test-read-dwarf/PR26261/PR26261-obj{a,b}.{c,h}: Likewise. * tests/data/test-read-dwarf/PR26261/Makefile: Makefile to build the exe out of the source files. * tests/data/Makefile.am: Add the new test input files to source distribution. * tests/test-read-dwarf.cc (in_out_spec): Add the binary test input above to the test harness. Signed-off-by: Dodji Seketeli Applied to master. --- src/abg-dwarf-reader.cc | 132 ++++++++++++--------- tests/data/Makefile.am | 8 ++ tests/data/test-read-dwarf/PR26261/Makefile | 21 ++++ tests/data/test-read-dwarf/PR26261/PR26261-exe | Bin 0 -> 10976 bytes tests/data/test-read-dwarf/PR26261/PR26261-exe.abi | 86 ++++++++++++++ tests/data/test-read-dwarf/PR26261/PR26261-main.c | 40 +++++++ tests/data/test-read-dwarf/PR26261/PR26261-obja.c | 6 + tests/data/test-read-dwarf/PR26261/PR26261-obja.h | 12 ++ tests/data/test-read-dwarf/PR26261/PR26261-objb.c | 6 + tests/data/test-read-dwarf/PR26261/PR26261-objb.h | 9 ++ tests/test-read-dwarf.cc | 7 ++ 11 files changed, 273 insertions(+), 54 deletions(-) create mode 100644 tests/data/test-read-dwarf/PR26261/Makefile create mode 100755 tests/data/test-read-dwarf/PR26261/PR26261-exe create mode 100644 tests/data/test-read-dwarf/PR26261/PR26261-exe.abi create mode 100644 tests/data/test-read-dwarf/PR26261/PR26261-main.c create mode 100644 tests/data/test-read-dwarf/PR26261/PR26261-obja.c create mode 100644 tests/data/test-read-dwarf/PR26261/PR26261-obja.h create mode 100644 tests/data/test-read-dwarf/PR26261/PR26261-objb.c create mode 100644 tests/data/test-read-dwarf/PR26261/PR26261-objb.h diff --git a/src/abg-dwarf-reader.cc b/src/abg-dwarf-reader.cc index 533c2dc..1184cbf 100644 --- a/src/abg-dwarf-reader.cc +++ b/src/abg-dwarf-reader.cc @@ -11874,76 +11874,100 @@ compare_dies(const read_context& ctxt, != aggregates_being_compared.end()) || (aggregates_being_compared.find(rn) != aggregates_being_compared.end())) - result = true; + { + result = true; + break; + } else if (l_tag == DW_TAG_subroutine_type) { - // The string reprs of l and r are already equal. Now - // let's just check if they both come from the same TU. + // So, we are looking at types that are pointed to by a + // function pointer. These are not real concrete function + // types, rather, they denote interfaces of functions. + // + // If the textual representations are different, then + // obviously they are different DIEs. + if (ln != rn) + { + result = false; + break; + } + + // So if their textual representation are the same and + // they come from the same TU, then they represent the + // same DIE. bool from_the_same_tu = false; if (compare_dies_cu_decl_file(l, r, from_the_same_tu) && from_the_same_tu) - result = true; - } - else - { - if (!fn_die_equal_by_linkage_name(ctxt, l, r)) { - result = false; + result = true; break; } + } - if (!ctxt.die_is_in_c(l) && !ctxt.die_is_in_c(r)) + if (l_tag == DW_TAG_subprogram + && !fn_die_equal_by_linkage_name(ctxt, l, r)) + { + result = false; + break; + } + else if (l_tag == DW_TAG_subprogram + && ctxt.die_is_in_c(l) && ctxt.die_is_in_c(r) + /*&& fn_die_equal_by_linkage_name(ctxt, l, r)*/) + { + result = true; + break; + } + else if (!ctxt.die_is_in_c(l) && !ctxt.die_is_in_c(r)) + { + // In C, we cannot have two different functions with the + // same linkage name in a given binary. But here we are + // looking at DIEs that don't originate from C. So we + // need to compare return types and parameter types. + Dwarf_Die l_return_type, r_return_type; + bool l_return_type_is_void = !die_die_attribute(l, DW_AT_type, + l_return_type); + bool r_return_type_is_void = !die_die_attribute(r, DW_AT_type, + r_return_type); + if (l_return_type_is_void != r_return_type_is_void + || (!l_return_type_is_void + && !compare_dies(ctxt, + &l_return_type, &r_return_type, + aggregates_being_compared, + update_canonical_dies_on_the_fly))) + result = false; + else { - // In C, we cannot have two different functions with the - // same linkage name in a given binary. But here we are - // looking at DIEs that don't originate from C. So we - // need to compare return types and parameter types. - Dwarf_Die l_return_type, r_return_type; - bool l_return_type_is_void = !die_die_attribute(l, DW_AT_type, - l_return_type); - bool r_return_type_is_void = !die_die_attribute(r, DW_AT_type, - r_return_type); - if (l_return_type_is_void != r_return_type_is_void - || (!l_return_type_is_void - && !compare_dies(ctxt, - &l_return_type, &r_return_type, - aggregates_being_compared, - update_canonical_dies_on_the_fly))) - result = false; - else - { - Dwarf_Die l_child, r_child; - bool found_l_child, found_r_child; - for (found_l_child = dwarf_child(const_cast(l), + Dwarf_Die l_child, r_child; + bool found_l_child, found_r_child; + for (found_l_child = dwarf_child(const_cast(l), + &l_child) == 0, + found_r_child = dwarf_child(const_cast(r), + &r_child) == 0; + found_l_child && found_r_child; + found_l_child = dwarf_siblingof(&l_child, &l_child) == 0, - found_r_child = dwarf_child(const_cast(r), - &r_child) == 0; - found_l_child && found_r_child; - found_l_child = dwarf_siblingof(&l_child, - &l_child) == 0, - found_r_child = dwarf_siblingof(&r_child, - &r_child)==0) + found_r_child = dwarf_siblingof(&r_child, + &r_child)==0) + { + int l_child_tag = dwarf_tag(&l_child); + int r_child_tag = dwarf_tag(&r_child); + if (l_child_tag != r_child_tag + || (l_child_tag == DW_TAG_formal_parameter + && !compare_dies(ctxt, &l_child, &r_child, + aggregates_being_compared, + update_canonical_dies_on_the_fly))) { - int l_child_tag = dwarf_tag(&l_child); - int r_child_tag = dwarf_tag(&r_child); - if (l_child_tag != r_child_tag - || (l_child_tag == DW_TAG_formal_parameter - && !compare_dies(ctxt, &l_child, &r_child, - aggregates_being_compared, - update_canonical_dies_on_the_fly))) - { - result = false; - break; - } + result = false; + break; } - if (found_l_child != found_r_child) - result = false; } + if (found_l_child != found_r_child) + result = false; } - - aggregates_being_compared.erase(ln); - aggregates_being_compared.erase(rn); } + + aggregates_being_compared.erase(ln); + aggregates_being_compared.erase(rn); } break; diff --git a/tests/data/Makefile.am b/tests/data/Makefile.am index ea94f0b..e59331e 100644 --- a/tests/data/Makefile.am +++ b/tests/data/Makefile.am @@ -496,6 +496,14 @@ test-read-dwarf/PR25042-libgdbm-clang-dwarf5.so.6.0.0.abi \ test-read-dwarf/test25-bogus-binary.elf \ test-read-dwarf/test26-bogus-binary.elf \ test-read-dwarf/test27-bogus-binary.elf \ +test-read-dwarf/PR26261/Makefile \ +test-read-dwarf/PR26261/PR26261-exe.abi \ +test-read-dwarf/PR26261/PR26261-obja.c \ +test-read-dwarf/PR26261/PR26261-objb.c \ +test-read-dwarf/PR26261/PR26261-exe \ +test-read-dwarf/PR26261/PR26261-main.c \ +test-read-dwarf/PR26261/PR26261-obja.h \ +test-read-dwarf/PR26261/PR26261-objb.h \ \ test-annotate/test0.abi \ test-annotate/test1.abi \ diff --git a/tests/data/test-read-dwarf/PR26261/Makefile b/tests/data/test-read-dwarf/PR26261/Makefile new file mode 100644 index 0000000..f66fa38 --- /dev/null +++ b/tests/data/test-read-dwarf/PR26261/Makefile @@ -0,0 +1,21 @@ +SRCS = PR26261-obja.c PR26261-objb.c PR26261-main.c +EXE = PR26261-exe +OBJS = $(SRCS:.c=.o) +CFLAGS = -Wall -g + +all: $(EXE) + +%.o: %.c + $(CC) $(CFLAGS) -c $< + +$(EXE): $(OBJS) + gcc -fPIC $(OBJS) -o $@ + +cleanobjs: + rm -rf $(OBJS) + +cleanexe: + rm $(EXE) + +clean: cleanobjs + rm -rf *~ diff --git a/tests/data/test-read-dwarf/PR26261/PR26261-exe b/tests/data/test-read-dwarf/PR26261/PR26261-exe new file mode 100755 index 0000000000000000000000000000000000000000..564a4247643942bbfd91c0e75653dffe80ce5851 GIT binary patch literal 10976 zcmeHNeQX@X6`$Sp$2pGAmk+=pK#q_IL*ujKd|*Id-w#hi*!Q;T0ZRFysgclE0Z|D%68-)_NpEL@pVm zN3ll2k_7CP2*WE>98m>Xk4VyMR(j1!kKu$0j3LjD=0;bKve%=VpolgJhz+uzfh0?9 z%LzA0xJgbWG|OPOq=aC|dY^%wQc)5g4I*lItMYfgyqr<!7FI))6es7ia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|XOErAxVb%IAm@yv>||kNWDit)lnqI@Oq8F$suc5)^yFqzJ)LcPla5lXf~OVnhu&`5_TY?#aNO2i=@Ea(611PiHe_gpILW zYSLnn<;$BPce>s`G4O3GfvMx z{6z7L@*3BT{J)Rj6P#rI?HUlZxLBX-Oa5O))GrL2?_bPb3B<3@b*QThE@MFjgZdl5 zKZkd7?EjE%O36ct!SPp1F1;EkZ*;oH5xEpU*R@BKzNN%#0BP>5-=z3=0vfp3zc5U1 zgqUa@9w_y}{N05Sde_MMTqk!Zeez3<<7YXBU&0u@yJXr_{!OJHC1tc={2o^bs!u4V ztlz8jdzC)Vll=$h|A5l(R0jF|>u#mb?`ugPRp_kzJpvx(gy+e1{NqYLSaAl|zZlTx zdVeC|A7Zja0`O7Le*dNCqjI#A6BE!=r1*9~pU)4=)P(9-P{CmQk12h2!{>}PrO)xQ z8O}e`j|cS48dDCLO23;06%6|SIrubx_Rr^*14_S#27N8)e;i|Y(<6TaB*yg}|6eI6 z&osjqpwsBn=X$bf^qFU}!-5>oJeYW>!AT(9h=W`YRpN#4kYAPM2 zcz9jj!kFJbpTDMPQfM5fN6pa8e+L78{n9y2IcR1@1zC^b*?>ORo6Sl;xZY|yC9D4i zMz(nVTnDbWKz%xZkJ((ekO4C&oBgpalhye<^O=6>C + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/data/test-read-dwarf/PR26261/PR26261-main.c b/tests/data/test-read-dwarf/PR26261/PR26261-main.c new file mode 100644 index 0000000..60ea256 --- /dev/null +++ b/tests/data/test-read-dwarf/PR26261/PR26261-main.c @@ -0,0 +1,40 @@ +/** + * + * In this test case, we want the first parameter of the function + * wrapped_call to be represented in the output abixml by a pointer to + * the same function type as the one pointed to by the types + * fn_ptr_type_a_t and fn_ptr_type_b_t. + * + * This means that we want the function type pointed by these three + * function pointer to be the same, as a result of the + * canonicalization of the DIEs that represent these three function + * types. + * + */ +#include "PR26261-obja.h" +#include "PR26261-objb.h" + +void +wrapped_call(void (*fun)(int, int), + int a, + int b) +{ + if (fun) + fun(a, b); +} + +int +main(int argc, char ** argv) +{ + struct SA sa = {0, 0, 0}; + struct SB sb = {0, 0}; + + sa.m1 = 0; + sb.m1 = 0; + + fun_obja(&sa); + fun_objb(&sb); + wrapped_call(sa.m2, sa.m1, sb.m1); + + return 0; +} diff --git a/tests/data/test-read-dwarf/PR26261/PR26261-obja.c b/tests/data/test-read-dwarf/PR26261/PR26261-obja.c new file mode 100644 index 0000000..04d6d00 --- /dev/null +++ b/tests/data/test-read-dwarf/PR26261/PR26261-obja.c @@ -0,0 +1,6 @@ +#include "PR26261-obja.h" + +void +fun_obja(struct SA* s __attribute__((unused))) +{ +} diff --git a/tests/data/test-read-dwarf/PR26261/PR26261-obja.h b/tests/data/test-read-dwarf/PR26261/PR26261-obja.h new file mode 100644 index 0000000..b6ca8f4 --- /dev/null +++ b/tests/data/test-read-dwarf/PR26261/PR26261-obja.h @@ -0,0 +1,12 @@ +typedef void (*fn_ptr_type_a_t)(int, int); + +typedef void (*fn_ptr_type_a2_t)(int, int); + +struct SA +{ + int m1; + fn_ptr_type_a_t m2; + fn_ptr_type_a2_t m3; +}; + +void fun_obja(struct SA*); diff --git a/tests/data/test-read-dwarf/PR26261/PR26261-objb.c b/tests/data/test-read-dwarf/PR26261/PR26261-objb.c new file mode 100644 index 0000000..49e26bf --- /dev/null +++ b/tests/data/test-read-dwarf/PR26261/PR26261-objb.c @@ -0,0 +1,6 @@ +#include "PR26261-objb.h" + +void +fun_objb(struct SB* s __attribute__((unused))) +{ +} diff --git a/tests/data/test-read-dwarf/PR26261/PR26261-objb.h b/tests/data/test-read-dwarf/PR26261/PR26261-objb.h new file mode 100644 index 0000000..92f92ca --- /dev/null +++ b/tests/data/test-read-dwarf/PR26261/PR26261-objb.h @@ -0,0 +1,9 @@ +typedef void (*fn_ptr_type_b_t)(int, int, char); + +struct SB +{ + int m1; + fn_ptr_type_b_t m2; +}; + +void fun_objb(struct SB*); diff --git a/tests/test-read-dwarf.cc b/tests/test-read-dwarf.cc index 8502f82..3f93d6d 100644 --- a/tests/test-read-dwarf.cc +++ b/tests/test-read-dwarf.cc @@ -373,6 +373,13 @@ InOutSpec in_out_specs[] = NULL, NULL, }, + { + "data/test-read-dwarf/PR26261/PR26261-exe", + "", + SEQUENCE_TYPE_ID_STYLE, + "data/test-read-dwarf/PR26261/PR26261-exe.abi", + "output/test-read-dwarf/PR26261/PR26261-exe.abi", + }, // This should be the last entry. {NULL, NULL, SEQUENCE_TYPE_ID_STYLE, NULL, NULL} };