From owner-freebsd-ppc@freebsd.org Sun Feb 14 19:31:28 2016 Return-Path: Delivered-To: freebsd-ppc@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 2EC16AA864E; Sun, 14 Feb 2016 19:31:28 +0000 (UTC) (envelope-from rdivacky@vlakno.cz) Received: from vlakno.cz (mail.vlakno.cz [91.217.96.224]) by mx1.freebsd.org (Postfix) with ESMTP id A178539D; Sun, 14 Feb 2016 19:31:27 +0000 (UTC) (envelope-from rdivacky@vlakno.cz) Received: by vlakno.cz (Postfix, from userid 1002) id A3DC71E2106D; Sun, 14 Feb 2016 20:29:03 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=vlakno.cz; s=mail; t=1455478143; bh=a3HfwErfTPWIfhkKugpsAhrXGlCbCrU9Ck90wIet0+Y=; h=Date:From:To:Cc:Subject:References:In-Reply-To; b=Mhi+zRPOREeFrs/caU6Kpm5LN4KveZl6/iM+98leyutSAYHeuGUGE2zFXzyvr6GFF zmYoK9jyL5Vp6+RTnQZHufuTYbu6MWZDTajUiXaKLkHZWCQuwcPa6zRrokF0GgSLCg XQ6bT0hU8sB8W5V7GsM5oTiPypIfY7/xYe38UqKI= Date: Sun, 14 Feb 2016 20:29:03 +0100 From: Roman Divacky To: Mark Millard Cc: FreeBSD PowerPC ML , FreeBSD Toolchain Subject: Re: I've submitted 207175 for a clang 3.8.0 va_list handling problem for powerpc Message-ID: <20160214192903.GA96697@vlakno.cz> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.24 (2015-08-30) X-BeenThere: freebsd-ppc@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: Porting FreeBSD to the PowerPC List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 14 Feb 2016 19:31:28 -0000 Fwiw, the code to handle the vaarg is in tools/clang/lib/CodeGen/TargetInfo.cpp:PPC32_SVR4_ABIInfo::EmitVAArg() You can take a look to see whats wrong. On Sat, Feb 13, 2016 at 07:03:29PM -0800, Mark Millard wrote: > I've isolated another clang 3.8.0 TARGET_ARCH=powerpc SEGV problem that shows up for using clang 3.8.0 to buildworld/installworld for powerpc. > > > ls -l -n / > > gets a SEGV. As listed in https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=207175 ( and https://llvm.org/bugs/show_bug.cgi?id=26605 ) the following simplified program also gets the SEGV on powerpc: > > > #include // for va_list, va_start, va_arg, va_end > > #include // for intmax_t > > > > intmax_t > > va_test (char *s, ...) > > { > > va_list vap; > > > > va_start(vap, s); > > > > char* t0 = va_arg(vap, char*); > > unsigned int o0 = va_arg(vap, unsigned int); > > int c0 = va_arg(vap, int); > > unsigned int u0 = va_arg(vap, unsigned int); > > int c1 = va_arg(vap, int); > > char * t1 = va_arg(vap, char*); > > > > intmax_t j0 = va_arg(vap, intmax_t); // This spans into overflow_arg_area. > > > > int c2 = va_arg(vap, int); // A copy was put in the > > // overflow_arg_area because of the > > // above. > > // But this tries to extract from the > > // last 4 bytes of the reg_save_area. > > // It does not increment the > > // overflow_arg_area position pointer > > // past the copy that is there. > > > > char * t2 = va_arg(vap, char*); // The lack of increment before makes > > // this extraction off by 4 bytes. > > > > char t2fc = *t2; // <<< This gets SEGV. t2 actually got what should be > > // the c2 value. > > > > intmax_t j1 = va_arg(vap, intmax_t); > > > > va_end(vap); > > > > return (intmax_t) ((s-t2)+(t0-t1)+o0+u0+j0+j1+c0+c1+c2+t2fc); > > // Avoid any optimize-away for lack of use. > > } > > > > int main(void) > > { > > char s[1025] = "test string for this"; > > > > char* t0 = s + 5; > > unsigned int o0 = 3; > > int c0 = 1; > > unsigned int u0 = 1; > > int c1 = 3; > > char * t1 = s + 12; > > intmax_t j0 = 314159265358979323; > > int c2 = 4; > > char * t2 = s + 16; > > intmax_t j1 = ~314159265358979323; > > > > intmax_t result = va_test(s,t0,o0,c0,u0,c1,t1,j0,c1,t2,j1); > > > > return (int) (result - (intmax_t) ((s-t2)+(t0-t1)+o0+u0+j0+j1+c0+c1+c2+*t2)); > > // Avoid any optimize-away for lack of use. > > } > > > > === > Mark Millard > markmi at dsl-only.net > > _______________________________________________ > freebsd-toolchain@freebsd.org mailing list > https://lists.freebsd.org/mailman/listinfo/freebsd-toolchain > To unsubscribe, send any mail to "freebsd-toolchain-unsubscribe@freebsd.org"